Total Complexity | 5 |
Total Lines | 34 |
Duplicated Lines | 0 % |
Coverage | 92.31% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
13 | use Yiisoft\Validator\ParametrizedRuleInterface; |
||
14 | |||
15 | final class Callback implements ParametrizedRuleInterface, PreValidatableRuleInterface |
||
16 | { |
||
17 | use HandlerClassNameTrait; |
||
18 | use PreValidatableTrait; |
||
19 | use RuleNameTrait; |
||
20 | |||
21 | 4 | public function __construct( |
|
22 | /** |
||
23 | * @var callable |
||
24 | */ |
||
25 | private $callback, |
||
26 | private bool $skipOnEmpty = false, |
||
27 | private bool $skipOnError = false, |
||
28 | private ?Closure $when = null, |
||
29 | ) { |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * @return callable |
||
34 | */ |
||
35 | 7 | public function getCallback(): callable |
|
36 | { |
||
37 | 7 | return $this->callback; |
|
38 | } |
||
39 | |||
40 | 2 | #[ArrayShape(['skipOnEmpty' => 'bool', 'skipOnError' => 'bool'])] |
|
41 | public function getOptions(): array |
||
42 | { |
||
43 | return [ |
||
44 | 2 | 'skipOnEmpty' => $this->skipOnEmpty, |
|
45 | 2 | 'skipOnError' => $this->skipOnError, |
|
46 | ]; |
||
47 | } |
||
49 |