Converts the phpDocumentor configuration xml to an array.

@param Uri $uri The location of the file to be loaded.

@return Configuration
@throws RuntimeException if no matching strategy can be found.
342390
public function fromUri(Uri $uri): Configuration
    {
        $filename = (string) $uri;

        if (!file_exists($filename)) {
            throw new \InvalidArgumentException(sprintf('File %s could not be found', $filename));
        }

        $xml = new \SimpleXMLElement($filename, 0, true);
        foreach ($this->strategies as $strategy) {
            if ($strategy->supports($xml) !== true) {
                continue;
            }

            return new Configuration($this->applyMiddleware($strategy->convert($xml)));
        }

        throw new RuntimeException('No supported configuration files were found');
    }
1186116
private static function parseURI($uri){
        //Remove protocol (for clarity).
        $uri = substr($uri, strlen('mmap://'));
        $parts = explode('?', $uri);

        $file_name_block_size = explode(':', $parts[0]);

        if(!isset($file_name_block_size[1])){
            throw new \Exception(sprintf('%s is not a valid uri', $uri));
        }

        $parsed = [];

        list($parsed['file_name'], $parsed['block_size']) = $file_name_block_size;

        if(isset($parts[1])){
            //Extra params
            parse_str($parts[1], $parsed['options']);
        } else {
            $parsed['options'] = [];
        }

        return $parsed;
    }
528496
public function resolveWriter(ResourceUri $resource)
    {
        if (! array_key_exists($resource->getProtocol(), $this->protocolWriterIndexes)) {
            throw new \RuntimeException('Unsupported protocol: ' . $resource->getProtocol() . '( ' . $resource  . ')');
        }

        /** @var int $index */
        $index = $this->protocolWriterIndexes[$resource->getProtocol()];

        return $this->writers[$index];
    }
1374396
static public function escapeUri(string $uri): string {
        self::initSerializer();
        return self::$serializer->serialiseValue(new Resource($uri));
    }
1248735
public function parse($uri)
    {
        if (($scheme = static::parseScheme($uri)) !== null) {
            $this->setScheme($scheme);
            $uri = substr($uri, strlen($scheme) + 1);
        }

        $parts = explode(',', $uri, 2);

        if (count($parts) > 1) {
            $mimeType = array_shift($parts);
            if (';base64' === substr($mimeType, -7)) {
                $this->encoding = 'base64';
                $mimeType = substr($mimeType, 0, -7);
            }
            $this->setMimeType($mimeType);
        }

        $this->rawData = array_shift($parts);

        return $this;
    }
72350
private function parseUri(string $uri): array
    {
        $defaults = [
            'scheme'   => '',
            'host'     => '',
            'port'     => '',
            'user'     => '',
            'pass'     => '',
            'path'     => '',
            'query'    => '',
            'fragment' => '',
        ];

        if (0 === strpos($uri, 'file://')) {
            // parse_url botches this up
            preg_match('@file://(?P<path>[^#]*)(?P<fragment>#.*)?@', $uri, $matches);

            return array_merge($defaults, array_intersect_key($matches, $defaults));
        }

        return array_merge($defaults, array_intersect_key(parse_url($uri), $defaults));
    }
43112
public function getVersion($uri)
    {
        $response = $this->guzzleclient->get($uri);
        $data = json_decode($response->getBody(), true);
        if (JSON_ERROR_NONE !== json_last_error()) {
            throw new RuntimeException('Unable to parse response body into JSON: ' . json_last_error());
        }
        return $data;
    }
437383
protected function get($uri=null)
    {
        if (!is_null($uri)) {
            if (!($this->getCrudService()->isInScope($uri))) {
                throw new common_exception_PreConditionFailure("The URI must be a valid resource under the root Class");
            }
            return $this->getCrudService()->get($uri);
        } else {
            return $this->getCrudService()->getAll();
        }
    }
866359
public function read(string $uri): Response
    {
        $contents = @file_get_contents($uri);

        if (false === $contents) {
            throw new ResourceNotReadableException("Failed reading '$uri'");
        }

        return new Response(
            preg_match('/\b(yml|yaml|raml)\b/', $uri) ? self::CONTENT_TYPE_YAML : self::CONTENT_TYPE_JSON,
            $contents
        );
    }
1092901
public function write($file)
    {
        $content = '';
        if ($this->section) {
            $content .= "[{$this->section}]\n";
        }

        foreach ($this->data as $key => $value) {
            if (is_array($value)) {
                $content .= $this->createArrayLines($value, $key);
                continue;
            }

            $content .= $this->createPropertyLine($key, $value);
        }

        if (file_put_contents($file, $content) === false) {
            throw new RuntimeException('Failed to write config file: ' . $file);
        }

        return $this;
    }
760446
public function &findPageByUri($uri)
    {
        foreach ($this->getPages() as $page) {
            if ($page->getUrl() == $uri) {
                return $page;
            }
        }

        foreach ($this->getSections() as $section) {
            $found = $section->findPageByUri($uri);
            if (! is_null($found)) {
                return $found;
            }
        }

        return;
    }
612394
public static function parseUri(string $uri){
        if(1 !== preg_match(static::REGEX_URI, $uri, $m)){
            return false;
        }

        $result = [
            "scheme"    => $m["scheme"] ?? "",
            "userinfo"  => $m["userinfo"] ?? "",
            "host"      => $m["host"] ?? "",
            "port"      => "" === $m["port"] ? null : (int)$m["port"],
            "path"      => $m["path"] ?? "",
            "query"     => $m["query"] ?? "",
            "fragment"  => $m["fragment"] ?? "",
        ];

        return $result;
    }
1367791
public function getConfig()
    {
        if ($this->config === null) {
            $path = $this->getInputDirectory() . '/makedocs.json';
            if (!is_file($path)) {
                throw new \RuntimeException('The input directory does not contain a makedocs.json file.');
            }

            $data = json_decode(file_get_contents($path));
            if (!$data) {
                throw new \RuntimeException('The JSON could not be loaded.');
            }

            $this->config = new Config((array)$data);
        }
        return $this->config;
    }
823926
private function createUri($uri)
    {
        if ($this->hasBaseUri() && (stripos($uri, $baseUri = (string) $this->getBaseUri()) === false)) {
            return $baseUri.$uri;
        }

        return $uri;
    }
191853
public function create($uri, $content)
    {
        $uri = '/' . trim($uri, '/');

        foreach ($this->patterns as $pattern => $key) {
            if (preg_match($pattern, $uri)) {
                return call_user_func($this->builders[$key], (array) $content);
            }
        }

        throw new RuntimeException(sprintf('Cannot create resource by URI "%s"', $uri));
    }
66728
public static function createFromUri($uri)
    {
        $name = substr($uri, strrpos($uri, '/'));
        $path = sprintf('%s/%s', sys_get_temp_dir(), $name);
        copy($uri, $path);
        return static::createFromPath($path);
    }
1248577
public function parse()
    {
        if (!is_string($this->data)) {
            throw new \RuntimeException('The given data is no valid string');
        }
        libxml_use_internal_errors(true);
        $xml = simplexml_load_string($this->data);
        if ($xml === false) {
            throw new \RuntimeException('Error during the loading of the XML file');
        }
        if (!isset($xml->executables, $xml->excludes)) {
            throw new \RuntimeException('Missing configuration elements');
        }

        foreach ($xml->excludes->children()->file as $file) {
            $this->config->addExcludedFile((string) $file);
        }

        foreach ($xml->excludes->children()->dir as $dir) {
            $this->config->addExcludedDir((string) $dir);
        }

        foreach ($xml->executables->children() as $file) {
            $this->config->addExecutableFile((string) $file);
        }

        return $this->config;
    }