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