src/ExtendedJsonConfig.php
protected function load(string $json, bool $jsonIsUrl = false, string $baseDirectory = null): array
    {
        // JSON string?
        if (!$jsonIsUrl) {
            return $this->loadJson($json);
        }

        $configuration = [];
        $localJsonLoading = [];

        do {
            if (!empty($baseDirectory)) {
                $json = realpath($path = sprintf('%s/%s', rtrim($baseDirectory, '\\/'), ltrim($json, '\\/')));
            }
            $baseDirectory = dirname($json);

            // Check recursive file call
            if (in_array($json, $this->jsonLoading)) {
                throw new ConfigException(sprintf('Recursive configuration inclusion/extend for file "%s"', $path ?? $json));
            }

            $configuration = b_array_merge_recursive($this->loadUrl($json), $configuration);

            // Get @extends value
            $extends = $json = $configuration['@extends'] ?? false;
            unset($configuration['@extends']);

            // Add JSON file to currently loading
            $this->jsonLoading[] = $localJsonLoading[] = $json;

            // Do inclusions
            array_walk_recursive($configuration, [$this, 'doInclusions'], $baseDirectory);
        } while ($extends !== false);

        // Remove JSON file from currently loading
        foreach ($localJsonLoading as $json) {
            if ($jsonIsUrl && ($key = array_search($json, $this->jsonLoading)) !== false) {
                unset($this->jsonLoading[$key]);
            }
        }

        return $configuration;
    }
protected function load(string $json, bool $jsonIsUrl = false, string $baseDirectory = null): array
    {
        // JSON string?
        if (!$jsonIsUrl) {
            return $this->loadJson($json);
        }

        $configuration = [];
        $localJsonLoading = [];

        do {
            if (!empty($baseDirectory)) {
                $json = realpath($path = sprintf('%s/%s', rtrim($baseDirectory, '\\/'), ltrim($json, '\\/')));
            }
            $baseDirectory = dirname($json);

            // Check recursive file call
            if (in_array($json, $this->jsonLoading)) {
                throw new ConfigException(sprintf('Recursive configuration inclusion/extend for file "%s"', $path ?? $json));
            }

            $configuration = b_array_merge_recursive($this->loadUrl($json), $configuration);

            // Get @extends value
            $extends = $json = $configuration['@extends'] ?? false;
            unset($configuration['@extends']);

            // Add JSON file to currently loading
            $this->jsonLoading[] = $localJsonLoading[] = $json;

            // Do inclusions
            array_walk_recursive($configuration, [$this, 'doInclusions'], $baseDirectory);
        } while ($extends !== false);

        // Remove JSON file from currently loading
        foreach ($localJsonLoading as $json) {
            if ($jsonIsUrl && ($key = array_search($json, $this->jsonLoading)) !== false) {
                unset($this->jsonLoading[$key]);
            }
        }

        return $configuration;
    }
Load configuration.

@param string      $json          JSON data
@param bool        $jsonIsUrl     If JSON data is URL? (default: false)
@param string|null $baseDirectory Base directory to get JSON file

@return array
@throws \Berlioz\Config\Exception\ConfigException
@throws \Berlioz\Config\Exception\NotFoundException