FluidXml\FluidNamespace::__invoke PHP Method

__invoke() public method

public __invoke ( $xpath )
    public function __invoke($xpath)
    {
        $id = $this->id();
        if (!empty($id)) {
            $id .= ':';
        }
        // An XPath query may not start with a slash ('/').
        // Relative queries are an example '../target".
        $new_xpath = '';
        $nodes = \explode('/', $xpath);
        foreach ($nodes as $node) {
            if (!empty($node)) {
                // An XPath query can have multiple slashes.
                // Example: //target
                $new_xpath .= "{$id}{$node}";
            }
            $new_xpath .= '/';
        }
        // Removes the last appended slash.
        return \substr($new_xpath, 0, -1);
    }