Conditions | 6 |
Paths | 13 |
Total Lines | 20 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
14 | 2 | public function convert(string $word): Traversable |
|
15 | { |
||
16 | 2 | if ($word === '') { |
|
17 | 2 | yield ''; |
|
18 | 2 | return; |
|
19 | } |
||
20 | |||
21 | 2 | $char = mb_substr($word, 0, 1); |
|
22 | |||
23 | 2 | $chars = [$char]; |
|
24 | 2 | if ($char !== mb_strtolower($char)) { |
|
25 | 2 | $chars[] = mb_strtolower($char); |
|
26 | } |
||
27 | 2 | if ($char !== mb_strtoupper($char)) { |
|
28 | 2 | $chars[] = mb_strtoupper($char); |
|
29 | } |
||
30 | |||
31 | 2 | foreach ($this->convert(mb_substr($word, 1)) as $suffix) { |
|
32 | 2 | foreach ($chars as $char) { |
|
33 | 2 | yield $char.$suffix; |
|
34 | } |
||
38 |