Conditions | 5 |
Paths | 5 |
Total Lines | 34 |
Code Lines | 26 |
Lines | 0 |
Ratio | 0 % |
Tests | 28 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
14 | 7 | public static function parseMisspellings(string $output, array $context): iterable |
|
15 | { |
||
16 | 7 | $lines = explode(PHP_EOL, $output); |
|
17 | 7 | $lineNumber = 1; |
|
18 | 7 | foreach ($lines as $line) { |
|
19 | 7 | $line = trim($line); |
|
20 | 7 | if ('' === $line) { |
|
21 | 7 | $lineNumber++; |
|
22 | // Go to the next line |
||
23 | 7 | continue; |
|
24 | } |
||
25 | |||
26 | 7 | switch ($line[0]) { |
|
27 | 7 | case '#': |
|
28 | 1 | list(, $word, $offset) = explode(' ', $line); |
|
29 | 1 | yield new Misspelling( |
|
|
|||
30 | 1 | $word, |
|
31 | 1 | (int) trim($offset), |
|
32 | 1 | $lineNumber, |
|
33 | 1 | [], |
|
34 | 1 | $context |
|
35 | ); |
||
36 | 1 | break; |
|
37 | 7 | case '&': |
|
38 | 7 | $parts = explode(':', $line); |
|
39 | 7 | list(, $word, , $offset) = explode(' ', $parts[0]); |
|
40 | 7 | yield new Misspelling( |
|
41 | 7 | $word, |
|
42 | 7 | (int) trim($offset), |
|
43 | 7 | $lineNumber, |
|
44 | 7 | explode(', ', trim($parts[1])), |
|
45 | 7 | $context |
|
46 | ); |
||
47 | 7 | break; |
|
48 | } |
||
52 |