| Conditions | 4 |
| Paths | 6 |
| Total Lines | 13 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 4 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 45 | 10 | public function getLevels(int $from = 1, ?int $to = null, ?callable $callback = null): array |
|
| 46 | { |
||
| 47 | 10 | $parts = explode('.', $this->env); |
|
| 48 | 10 | $n = isset($to) ? min(count($parts), $to) : count($parts); |
|
| 49 | |||
| 50 | 10 | $levels = []; |
|
| 51 | |||
| 52 | 10 | for ($i = $from; $i <= $n; $i++) { |
|
| 53 | 10 | $level = join('.', array_slice($parts, 0, $i)); |
|
| 54 | 10 | $levels[] = isset($callback) ? $callback($level) : $level; |
|
| 55 | } |
||
| 56 | |||
| 57 | 10 | return $levels; |
|
| 58 | } |
||
| 60 |