Conditions | 3 |
Paths | 3 |
Total Lines | 14 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 3 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php declare(strict_types=1); |
||
17 | 6 | public function getExpr(QueryBuilder $qb, int $index, Filter $filter) |
|
18 | { |
||
19 | 6 | $expr = $qb->expr()->like($filter->getField(), '?'.$index); |
|
20 | |||
21 | 6 | $search = trim($filter->getX() ?? ''); |
|
22 | |||
23 | 6 | if ($filter->getExtra() !== 'exact') { |
|
24 | 5 | $words = preg_split('/[\s\.,]+/', $search); |
|
25 | 5 | $search = $words ? implode('%', $words) : $search; |
|
26 | } |
||
27 | |||
28 | 6 | $qb->setParameter($index, '%'.$search.'%'); |
|
29 | |||
30 | 6 | return $expr; |
|
31 | } |
||
32 | } |