Lines 100.00% 2 / 2
Functions and Methods 100.00% 2 / 2
Classes and Traits 100.00% 1 / 1
Name Lines Functions and Methods CRAP Classes and Traits
Filter 100.00% 2 / 2 100.00% 2 / 2 2 100.00% 1 / 1
 __construct 100.00% 1 / 1 100.00% 1 / 1 1
 dqlLike 100.00% 1 / 1 100.00% 1 / 1 1
1<?php
2
3declare(strict_types=1);
4
5namespace Districts\Editor\Infrastructure\Doctrine;
6
7abstract readonly class Filter
8{
9    /**
10     * @param array<string, scalar> $parameters
11     */
12    protected function __construct(
13        public string $where,
14        public array $parameters,
15    ) {
16    }
17
18    protected static function dqlLike(string $string): string
19    {
20        // Doctrine will handle SQL injections, we just need to escape the LIKE syntax
21        return "%" . addcslashes($string, "%_") . "%";
22    }
23}