| Conditions | 4 |
| Paths | 4 |
| Total Lines | 26 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 4.0119 |
| Changes | 0 | ||
| 1 | <?php |
||
| 20 | 3 | private function applyDataTemplate(array $data, array $dataTemplate): array |
|
| 21 | { |
||
| 22 | /** @var array $result */ |
||
| 23 | 3 | $result = array(); |
|
| 24 | |||
| 25 | 3 | foreach ($dataTemplate as $key => $templateEntry) { |
|
| 26 | /** @var string|array $templateEntry */ |
||
| 27 | |||
| 28 | /** @var mixed $entryResult */ |
||
| 29 | 3 | $entryResult = null; |
|
|
|
|||
| 30 | |||
| 31 | 3 | if (is_string($templateEntry)) { |
|
| 32 | 3 | $entryResult = $this->extractValueFromDataArray($data, explode(".", $templateEntry)); |
|
| 33 | |||
| 34 | 1 | } elseif (is_array($templateEntry)) { |
|
| 35 | $entryResult = $this->applyDataTemplate($data, $templateEntry); |
||
| 36 | |||
| 37 | } else { |
||
| 38 | 1 | throw new ErrorException("Invalid entry for data-template, must be string or array!"); |
|
| 39 | } |
||
| 40 | |||
| 41 | 3 | $result[$key] = $entryResult; |
|
| 42 | } |
||
| 43 | |||
| 44 | 2 | return $result; |
|
| 45 | } |
||
| 46 | |||
| 70 |
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.