Conditions | 4 |
Paths | 4 |
Total Lines | 17 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
17 | 16 | public static function expand(array $hostnames): array |
|
18 | 16 | { |
|
19 | 3 | $expanded = []; |
|
20 | 3 | foreach ($hostnames as $hostname) { |
|
21 | if (preg_match(self::PATTERN, $hostname, $matches)) { |
||
22 | 3 | [$start, $end] = explode(':', $matches[1]); |
|
23 | 3 | $zeroBased = (bool) preg_match('/^0[1-9]/', $start); |
|
24 | |||
25 | foreach (range($start, $end) as $i) { |
||
26 | 15 | $expanded[] = preg_replace(self::PATTERN, self::format((string) $i, $zeroBased), $hostname); |
|
27 | } |
||
28 | } else { |
||
29 | $expanded[] = $hostname; |
||
30 | 16 | } |
|
31 | } |
||
32 | |||
33 | 3 | return $expanded; |
|
34 | } |
||
45 |