Conditions | 4 |
Paths | 4 |
Total Lines | 15 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
23 | public static function deserialize(string $string): Grid |
||
24 | { |
||
25 | if (strlen($string) !== Grid::NUMBER_OF_LOCATIONS) { |
||
26 | throw new LengthException(); |
||
27 | } |
||
28 | $grid = new Grid(); |
||
29 | for ($i = 0; $i < Grid::NUMBER_OF_LOCATIONS; $i++) { |
||
30 | $location = self::getLocationByIndex($i); |
||
31 | $value = (int) $string[$i]; |
||
32 | if (Grid::valueIsValid($value)) { |
||
33 | $grid->set($location, $value); |
||
34 | } |
||
35 | } |
||
36 | |||
37 | return $grid; |
||
38 | } |
||
48 |