Conditions | 4 |
Paths | 5 |
Total Lines | 16 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
14 | 27 | public static function computeErasingWidths(array $strings): int |
|
15 | { |
||
16 | 27 | if (empty($strings)) { |
|
17 | 1 | return 0; |
|
18 | } |
||
19 | 26 | $lengths = []; |
|
20 | 26 | foreach ($strings as $key => $string) { |
|
21 | 26 | $length = self::computeErasingWidth($string); |
|
22 | 26 | $lengths[] = $length; |
|
23 | 26 | $strings[$key] = [$length, $string]; |
|
24 | } |
||
25 | 26 | if (1 !== count(array_unique($lengths))) { |
|
26 | // dump($strings); |
||
27 | 1 | throw new \InvalidArgumentException('Strings have different erasing lengths.'); |
|
28 | } |
||
29 | 25 | return $lengths[0]; |
|
30 | } |
||
45 |