protected function getConfigReader() { if ($this->configReader === null) { $extension = pathinfo($this->getConfigPath(), PATHINFO_EXTENSION); switch ($extension) { case 'php': $this->configReader = new PhpConfigReader(); $this->configReader->setConfigPath($this->getConfigPath()); break; case 'json': $this->configReader = new JsonConfigReader(); $this->configReader->setConfigPath($this->getConfigPath()); break; case 'yml': case 'yaml': $this->configReader = new YamlConfigReader(); $this->configReader->setConfigPath($this->getConfigPath()); break; default: throw new RuntimeException("Config format {$extension} isn't supported"); } } return $this->configReader; }
private function getConfig() { // create config reader if is't created if ($this->configReader === null) { if ($this->configReaderConfig === null) { throw new RuntimeException('Config reader config should not empty'); } $configReaderConfig = $this->configReaderConfig; if (!isset($configReaderConfig['class'])) { throw new RuntimeException('You should specify config reader class'); } $configReaderClass = $configReaderConfig['class']; unset($configReaderConfig['class']); $this->configReader = $this->create($configReaderClass, $configReaderConfig); } return $this->configReader->getConfig(); }