Conditions | 4 |
Paths | 4 |
Total Lines | 15 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php declare(strict_types=1); |
||
26 | public function fromString(string $puzzle): Puzzle |
||
27 | { |
||
28 | $pieces = []; |
||
29 | $puzzle = str_replace(' ', '', $puzzle); |
||
30 | foreach (preg_split("/(\n)|(\r)/", $puzzle) as $line) { |
||
31 | if (empty($line)) { |
||
32 | continue; |
||
33 | } |
||
34 | $row = []; |
||
35 | foreach (explode($this->separator, $line) as $value) { |
||
36 | $row[] = (int) $value; |
||
37 | } |
||
38 | $pieces[] = $row; |
||
39 | } |
||
40 | return SlidingPuzzle::withPieces(...$pieces); |
||
41 | } |
||
43 |