Conditions | 7 |
Paths | 13 |
Total Lines | 19 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 7 |
Changes | 0 |
1 | <?php |
||
55 | 2 | public function convert(string $word): Traversable |
|
56 | { |
||
57 | 2 | if ($word === '') { |
|
58 | 2 | yield ''; |
|
59 | 2 | return; |
|
60 | } |
||
61 | |||
62 | 2 | $decodeMap = []; |
|
63 | 2 | foreach ($this->decodeMap as $encodedChar => $chars) { |
|
64 | 2 | if ((string)$encodedChar === mb_substr($word, 0, mb_strlen((string)$encodedChar))) { |
|
65 | 2 | $decodeMap[$encodedChar] = $chars; |
|
66 | } |
||
67 | } |
||
68 | 2 | $decodeMap[mb_substr($word, 0, 1)][] = mb_substr($word, 0, 1); |
|
69 | |||
70 | 2 | foreach ($decodeMap as $encodedChar => $chars) { |
|
71 | 2 | foreach ($this->convert(mb_substr($word, mb_strlen((string)$encodedChar))) as $suffix) { |
|
72 | 2 | foreach ($chars as $char) { |
|
73 | 2 | yield $char.$suffix; |
|
74 | } |
||
79 |