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