| Conditions | 4 |
| Paths | 4 |
| Total Lines | 18 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 32 | 4 | public static function extract(array $data, string $path) |
|
| 33 | { |
||
| 34 | 4 | if ('' === $path) { |
|
| 35 | 1 | return $data; |
|
| 36 | } |
||
| 37 | |||
| 38 | 3 | $steps = explode('.', $path); |
|
| 39 | 3 | $actual = $data; |
|
| 40 | 3 | foreach ($steps as $step) { |
|
| 41 | 3 | if (!array_key_exists($step, $actual)) { |
|
| 42 | 1 | return null; |
|
| 43 | } |
||
| 44 | |||
| 45 | 2 | $actual = $actual[$step]; |
|
| 46 | } |
||
| 47 | |||
| 48 | 2 | return $actual; |
|
| 49 | } |
||
| 50 | |||
| 65 |