| Conditions | 2 |
| Paths | 2 |
| Total Lines | 27 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 19 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 29 | 2 | public function fromPath($path) |
|
| 30 | { |
||
| 31 | /** @var SplFileInfo|null $file */ |
||
| 32 | 2 | $file = null; |
|
|
|
|||
| 33 | 2 | $finder = $this->finder |
|
| 34 | 2 | ->in($path) |
|
| 35 | 2 | ->files() |
|
| 36 | 2 | ->name(ConfigurationWriter::FILENAME) |
|
| 37 | 2 | ->depth(0); |
|
| 38 | |||
| 39 | 2 | $file = $finder->getIterator()->current(); |
|
| 40 | |||
| 41 | 2 | if (null === $file) { |
|
| 42 | 1 | throw new FileNotFoundException( |
|
| 43 | 1 | null, |
|
| 44 | 1 | 0, |
|
| 45 | 1 | null, |
|
| 46 | 1 | sprintf( |
|
| 47 | 1 | 'File %s not found in %s', |
|
| 48 | 1 | ConfigurationWriter::FILENAME, |
|
| 49 | $path |
||
| 50 | 1 | ) |
|
| 51 | 1 | ); |
|
| 52 | } |
||
| 53 | |||
| 54 | 1 | return $this->serializer->deserialize($file->getContents(), Configuration::class, ComposerEncoder::FORMAT); |
|
| 55 | } |
||
| 56 | } |
||
| 57 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.