| Conditions | 5 |
| Paths | 2 |
| Total Lines | 28 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 5 |
| Changes | 0 | ||
| 1 | <?php |
||
| 21 | 73 | public static function fromList(array $words, array $options = []) |
|
| 22 | { |
||
| 23 | $options += [ |
||
| 24 | 73 | 'delimiter' => '/', |
|
| 25 | 'caseInsensitive' => false, |
||
| 26 | 'specialChars' => [], |
||
| 27 | 'unicode' => true |
||
| 28 | ]; |
||
| 29 | |||
| 30 | // Normalize ASCII if the regexp is meant to be case-insensitive |
||
| 31 | 73 | if ($options['caseInsensitive']) |
|
| 32 | { |
||
| 33 | 2 | foreach ($words as &$word) |
|
| 34 | { |
||
| 35 | 2 | $word = strtr($word, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'); |
|
| 36 | } |
||
| 37 | 2 | unset($word); |
|
| 38 | } |
||
| 39 | |||
| 40 | 73 | $builder = new Builder([ |
|
| 41 | 73 | 'delimiter' => $options['delimiter'], |
|
| 42 | 73 | 'meta' => $options['specialChars'], |
|
| 43 | 73 | 'input' => $options['unicode'] ? 'Utf8' : 'Bytes', |
|
| 44 | 73 | 'output' => $options['unicode'] ? 'Utf8' : 'Bytes' |
|
| 45 | ]); |
||
| 46 | |||
| 47 | 73 | return $builder->build($words); |
|
| 48 | } |
||
| 49 | } |