Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
7 / 7 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| FieldTextSearchFilter | |
100.00% |
7 / 7 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getFilterName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getWhereCondition | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | namespace Apie\DoctrineEntityDatalayer\Query; |
| 3 | |
| 4 | use Apie\Core\Datalayers\Search\QuerySearch; |
| 5 | use Apie\DoctrineEntityDatalayer\LikeUtils; |
| 6 | use Doctrine\DBAL\Connection; |
| 7 | |
| 8 | final class FieldTextSearchFilter implements FieldSearchFilterInterface |
| 9 | { |
| 10 | public function __construct( |
| 11 | private readonly string $filterName, |
| 12 | private readonly string $searchTable |
| 13 | ) { |
| 14 | } |
| 15 | |
| 16 | public function getFilterName(): string |
| 17 | { |
| 18 | return $this->filterName; |
| 19 | } |
| 20 | |
| 21 | public function getWhereCondition(QuerySearch $querySearch, Connection $connection): string |
| 22 | { |
| 23 | return 'entity.id IN (SELECT parent_id as id FROM ' |
| 24 | . $this->searchTable |
| 25 | . ' WHERE value LIKE ' |
| 26 | . $connection->quote(LikeUtils::toLikeString($querySearch->getSearches()[$this->filterName])) |
| 27 | . ')'; |
| 28 | } |
| 29 | } |