Total Complexity | 8 |
Total Lines | 38 |
Duplicated Lines | 0 % |
Coverage | 84.21% |
Changes | 0 |
1 | <?php |
||
9 | class PipelineBuilder implements PipelineBuilderContract |
||
10 | { |
||
11 | private $filterDict = []; |
||
12 | |||
13 | 10 | public function registerFilter(FilterContract $filter, string $name = null): PipelineBuilderContract |
|
14 | { |
||
15 | 10 | if ($name === null) { |
|
16 | 1 | $name = $this->detectName($filter); |
|
17 | } |
||
18 | 10 | $this->filterDict[$name] = $filter; |
|
19 | 10 | return $this; |
|
20 | } |
||
21 | |||
22 | 10 | public function make($filterNames){ |
|
23 | $filters = array_map(function($name) { |
||
24 | 10 | if (is_string($name)) { |
|
25 | 10 | return $this->filterDict[$name]; |
|
26 | } else { |
||
27 | 1 | return $name; |
|
28 | } |
||
29 | 10 | }, $filterNames); |
|
30 | |||
31 | 10 | return new Pipeline($filters); |
|
32 | } |
||
33 | |||
34 | 1 | private function detectName(FilterContract $filter) { |
|
37 | } |
||
38 | |||
39 | 1 | private function getClassName($obj) { |
|
41 | } |
||
42 | |||
43 | public function registerFilters(array $filters) |
||
47 | } |
||
48 | } |
||
49 | } |