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