1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace WebServCo\Framework\DataTables; |
||
6 | |||
7 | class SearchHelper extends AbstractHelper |
||
8 | { |
||
9 | /** |
||
10 | * @param array<string,mixed> $data |
||
11 | * @param array<int,string> $required |
||
12 | */ |
||
13 | public static function init(array $data, array $required = []): Search |
||
14 | { |
||
15 | $required = $required; // reserved for future use. |
||
0 ignored issues
–
show
Unused Code
introduced
by
Loading history...
|
|||
16 | |||
17 | parent::validate($data, ['value', 'regex']); |
||
18 | |||
19 | foreach (['value', 'regex'] as $item) { |
||
20 | if (!isset($data[$item])) { |
||
21 | throw new \InvalidArgumentException(\sprintf('Missing search parameter: %s.', $item)); |
||
22 | } |
||
23 | } |
||
24 | |||
25 | return new Search($data['value'], \filter_var($data['regex'], \FILTER_VALIDATE_BOOLEAN)); |
||
26 | } |
||
27 | } |
||
28 |