| Conditions | 3 |
| Paths | 4 |
| Total Lines | 29 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 29 | public function fromPath($path) |
||
| 30 | { |
||
| 31 | /** @var SplFileInfo|null $file */ |
||
| 32 | $file = null; |
||
| 33 | $finder = $this->finder |
||
| 34 | ->in($path) |
||
| 35 | ->files() |
||
| 36 | ->name(ConfigurationWriter::FILENAME) |
||
| 37 | ->depth(0); |
||
| 38 | |||
| 39 | foreach ($finder as $match) { |
||
| 40 | $file = $match; |
||
| 41 | } |
||
| 42 | |||
| 43 | if (null === $file) { |
||
| 44 | throw new FileNotFoundException( |
||
| 45 | null, |
||
| 46 | 0, |
||
| 47 | null, |
||
| 48 | sprintf( |
||
| 49 | 'File %s not found in %s', |
||
| 50 | ConfigurationWriter::FILENAME, |
||
| 51 | $path |
||
| 52 | ) |
||
| 53 | ); |
||
| 54 | } |
||
| 55 | |||
| 56 | return $this->serializer->deserialize($file->getContents(), Configuration::class, ComposerEncoder::FORMAT); |
||
| 57 | } |
||
| 58 | } |
||
| 59 |