src/Configuration.php
private function parseConfiguration(string $stage = self::DEFAULT_STAGE)
    {
        $pattern = $this->getPath() . '/' . $stage . '/*.yaml';
        $files   = glob($pattern, GLOB_NOSORT | GLOB_ERR);

        if ($files === false || count($files) < 1) {
            $message = "Glob does not walk to files, pattern: {$pattern}. Path is correct?";
            throw new InvalidArgumentException($message);
        }

        $this->logger->debug('Following config files found:', $files);

        $config = [];
        foreach ($files as $filename) {
            $content   = Yaml::parseFile($filename);
            $directory = basename(pathinfo($filename, PATHINFO_DIRNAME));
            $top       = key($content);

            if ($directory !== $top) {
                $message = 'Invalid! Stage of config directory [%s] is not equals top of yaml content [%s].';
                throw new InvalidArgumentException(sprintf($message, $directory, $top));
            }

            $this->logger->debug(sprintf('Config %s/%s [top=%s] is fine.', $directory, basename($filename), $top));

            $config = $this->arrayMergeRecursive($config, current($content));
        }

        return $config;
    }
private function parseConfiguration(string $stage = self::DEFAULT_STAGE)
    {
        $pattern = $this->getPath() . '/' . $stage . '/*.yaml';
        $files   = glob($pattern, GLOB_NOSORT | GLOB_ERR);

        if ($files === false || count($files) < 1) {
            $message = "Glob does not walk to files, pattern: {$pattern}. Path is correct?";
            throw new InvalidArgumentException($message);
        }

        $this->logger->debug('Following config files found:', $files);

        $config = [];
        foreach ($files as $filename) {
            $content   = Yaml::parseFile($filename);
            $directory = basename(pathinfo($filename, PATHINFO_DIRNAME));
            $top       = key($content);

            if ($directory !== $top) {
                $message = 'Invalid! Stage of config directory [%s] is not equals top of yaml content [%s].';
                throw new InvalidArgumentException(sprintf($message, $directory, $top));
            }

            $this->logger->debug(sprintf('Config %s/%s [top=%s] is fine.', $directory, basename($filename), $top));

            $config = $this->arrayMergeRecursive($config, current($content));
        }

        return $config;
    }
private function parseConfiguration ( string $ stage = self :: DEFAULT_STAGE ) { $ pattern = $ this -> getPath ( ) . '/' . $ stage . '/*.yaml' ; $ files = glob ( $ pattern , GLOB_NOSORT | GLOB_ERR ) ; if ( $ files === false || count ( $ files ) < 1 ) { $ message = "Glob does not walk to files, pattern: {$pattern}. Path is correct?" ; throw new InvalidArgumentException ( $ message ) ; } $ this -> logger -> debug ( 'Following config files found:' , $ files ) ; $ config = [ ] ; foreach ( $ files as $ filename ) { $ content = Yaml :: parseFile ( $ filename ) ; $ directory = basename ( pathinfo ( $ filename , PATHINFO_DIRNAME ) ) ; $ top = key ( $ content ) ; if ( $ directory !== $ top ) { $ message = 'Invalid! Stage of config directory [%s] is not equals top of yaml content [%s].' ; throw new InvalidArgumentException ( sprintf ( $ message , $ directory , $ top ) ) ; } $ this -> logger -> debug ( sprintf ( 'Config %s/%s [top=%s] is fine.' , $ directory , basename ( $ filename ) , $ top ) ) ; $ config = $ this -> arrayMergeRecursive ( $ config , current ( $ content ) ) ; } return $ config ; }
Parses configuration and makes a tree of it

@param string $stage
@return array
Parses configuration and makes a tree of it