Total Complexity | 5 |
Total Lines | 47 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
7 | class Boolean extends AbstractBooleanCase implements SanitizeRuleInterface |
||
8 | { |
||
9 | /** @var bool|mixed */ |
||
10 | protected $trueValue; |
||
11 | |||
12 | /** @var bool|mixed */ |
||
13 | protected $falseValue; |
||
14 | |||
15 | /** |
||
16 | * @param bool $true Use this value for `true`. |
||
17 | * @param bool $false Use this value for `false`. |
||
18 | */ |
||
19 | 114 | public function __construct($true = true, $false = false) |
|
20 | { |
||
21 | 114 | $this->trueValue = $true; |
|
22 | 114 | $this->falseValue = $false; |
|
23 | 114 | } |
|
24 | |||
25 | /** |
||
26 | * Sanitize the value to a boolean, or a pseudo-boolean. |
||
27 | * |
||
28 | * @param object $subject The subject to be filtered. |
||
29 | * @param string $field The subject field name. |
||
30 | * @param mixed $true Use this value for `true`. |
||
31 | * @param mixed $false Use this value for `false`. |
||
32 | * |
||
33 | * @return bool Always true. |
||
34 | */ |
||
35 | 108 | public function __invoke($subject, string $field): bool |
|
54 | } |
||
55 | } |
||
56 |