Conditions | 3 |
Paths | 3 |
Total Lines | 14 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 3 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | 3 | public static function spin(string $text): string |
|
8 | { |
||
9 | 3 | if (! preg_match('/\{(.*)\}/si', $text)) { |
|
10 | 3 | return self::removeExtraSpaces($text); |
|
11 | } else { |
||
12 | 3 | preg_match_all('/\{([^{}]*)\}/si', $text, $matches); |
|
13 | 3 | $occur = count($matches[1]); |
|
14 | 3 | for ($i = 0; $i < $occur; ++$i) { |
|
15 | 3 | $words = explode('|', $matches[1][$i]); |
|
16 | 3 | shuffle($words); |
|
17 | 3 | $text = self::replaceOnce($matches[0][$i], $words[0], $text); |
|
18 | } |
||
19 | |||
20 | 3 | return self::spin($text); |
|
21 | } |
||
42 |