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; }