/** * @param string $path * @param int|null $format * @return $this */ protected function loadConfiguration($path, $format = null) { $readerRegistry = ReaderRegistry::getDefaultInstance(); $reader = $readerRegistry->getInstanceForFormat($format ?: Format::guessFormatFromPath($path)); $this->configuration = $reader->readFromFile($path); return $this; }
/** * @return array * @throws TaskException */ protected function readFromBoilerplate() { if (is_string($this->boilerplatePath)) { if (!file_exists($this->boilerplatePath) || !is_file($this->boilerplatePath)) { throw new TaskException($this, 'Cannot open boilerplate file ' . $this->boilerplatePath); } $format = $this->boilerplateFormat ?: Format::guessFormatFromPath($this->boilerplatePath); $reader = $this->getReaderRegistry()->getInstanceForFormat($format); return $reader->readFromFile($this->boilerplatePath); } else { return array(); } }
/** * @test * @expectedException \NordCode\RoboParameters\Exception\FormatException */ public function testGuessFormatFormPathFailsForUnknownFormat() { Format::guessFormatFromPath('nope'); }