| Conditions | 1 |
| Paths | 1 |
| Total Lines | 7 |
| Code Lines | 4 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | public static function detectDate(SplFileInfo $file) : DateTimeInterface |
||
| 17 | { |
||
| 18 | preg_match('/(\d{4})[\/\-]*(\d{2})[\/\-]*(\d{2})[\/\-]*(\d+|)/', $file->getFilename(), $matches); |
||
| 19 | list($dummy, $year, $month, $day) = $matches; |
||
|
|
|||
| 20 | |||
| 21 | return new DateTime(implode('-', [$year, $month, $day])); |
||
| 22 | } |
||
| 23 | |||
| 31 |
This checks looks for assignemnts to variables using the
list(...)function, where not all assigned variables are subsequently used.Consider the following code example.
Only the variables
$aand$care used. There was no need to assign$b.Instead, the list call could have been.