Total Complexity | 9 |
Total Lines | 52 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
9 | final class Filter |
||
10 | { |
||
11 | /** @var string */ |
||
12 | private $name; |
||
13 | |||
14 | /** @var mixed */ |
||
15 | private $value; |
||
16 | |||
17 | /** @var DataTransformer */ |
||
18 | private $transformer; |
||
19 | |||
20 | 6 | public function __construct(string $name, $value, DataTransformer $transformer = null) |
|
21 | { |
||
22 | 6 | $this->name = $name; |
|
23 | 6 | $this->value = $this->trim($value); |
|
24 | 6 | $this->transformer = $transformer ?? new NullTransformer(); |
|
25 | 6 | } |
|
26 | |||
27 | 4 | public function simplifiedValue() |
|
28 | { |
||
29 | 4 | if ($this->value === null) { |
|
30 | 1 | return null; |
|
31 | } |
||
32 | |||
33 | 3 | return $this->transformer->simplify($this->value); |
|
34 | } |
||
35 | |||
36 | 4 | public function transformedValue() |
|
43 | } |
||
44 | |||
45 | 3 | public function name(): string |
|
46 | { |
||
47 | 3 | return $this->name; |
|
48 | } |
||
49 | |||
50 | 6 | private function trim($value) |
|
61 | } |
||
62 | } |
||
63 |