Conditions | 3 |
Paths | 3 |
Total Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
28 | 24 | public function decorate(&$queryStringParams, SearchCriteria $criteria) |
|
29 | { |
||
30 | 24 | $q = $criteria->getSearch(); |
|
31 | |||
32 | // Add `*` only if : |
||
33 | // - not contain wildcard on end |
||
34 | // - not have space on end |
||
35 | // - ends with letter |
||
36 | // NOTE: Passing two wildcards to query will yield nothing, |
||
37 | // thats why it is checked too. |
||
38 | 24 | if (!preg_match('~\*$~u', $q)) |
|
39 | { |
||
40 | // Add `*` only if ends with any alphabet letter (phrase_prefix) |
||
41 | 23 | if (preg_match('~\p{L}$~u', $q)) |
|
42 | { |
||
43 | 17 | $q .= '*'; |
|
44 | } |
||
45 | } |
||
46 | 24 | $queryStringParams['query'] = $q; |
|
47 | 24 | } |
|
48 | |||
50 |