1 | <?php |
||
2 | |||
3 | namespace eloquentFilter\QueryFilter\Detection; |
||
4 | |||
5 | use eloquentFilter\QueryFilter\Detection\Contract\DetectorFactoryContract; |
||
6 | use Illuminate\Database\Eloquent\Model; |
||
7 | |||
8 | /** |
||
9 | * Class DetectionFactory. |
||
10 | */ |
||
11 | class DetectionFactory implements DetectorFactoryContract |
||
12 | { |
||
13 | /** |
||
14 | * @var array |
||
15 | */ |
||
16 | public array $detections; |
||
17 | |||
18 | /** |
||
19 | * DetectionFactory constructor. |
||
20 | * |
||
21 | * @param array $detections |
||
22 | */ |
||
23 | public function __construct(array $detections) |
||
24 | { |
||
25 | $this->detections = $detections; |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * @param $field |
||
30 | * @param $params |
||
31 | * @param Model|null $model |
||
32 | * |
||
33 | * @return mixed|string|null |
||
34 | * @throws \ReflectionException |
||
35 | * |
||
36 | */ |
||
37 | public function buildDetections($field, $params, $model = null): ?string |
||
38 | { |
||
39 | $detect = app(DetectorCondition::class, ['detector' => $this->detections]); |
||
40 | |||
41 | /** @see DetectorCondition::detect() */ |
||
42 | $method = $detect->detect($field, $params, $model); |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
43 | |||
44 | return $method; |
||
45 | } |
||
46 | } |
||
47 |