| Total Complexity | 5 |
| Total Lines | 61 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | final class CheckerRule extends AbstractRule |
||
| 17 | { |
||
| 18 | /** @var CheckerInterface */ |
||
| 19 | private $checker; |
||
| 20 | |||
| 21 | /** @var string */ |
||
| 22 | private $method; |
||
| 23 | |||
| 24 | /** @var array */ |
||
| 25 | private $args; |
||
| 26 | |||
| 27 | /** @var string|null */ |
||
| 28 | private $message; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @param CheckerInterface $checker |
||
| 32 | * @param string $method |
||
| 33 | * @param array $args |
||
| 34 | * @param null|string $message |
||
| 35 | */ |
||
| 36 | public function __construct( |
||
| 37 | CheckerInterface $checker, |
||
| 38 | string $method, |
||
| 39 | array $args = [], |
||
| 40 | ?string $message = null |
||
| 41 | ) { |
||
| 42 | $this->checker = $checker; |
||
| 43 | $this->method = $method; |
||
| 44 | $this->args = $args; |
||
| 45 | $this->message = $message; |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @inheritdoc |
||
| 50 | */ |
||
| 51 | public function ignoreEmpty($value): bool |
||
| 52 | { |
||
| 53 | return $this->checker->ignoreEmpty($this->method, $value, $this->args); |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @inheritdoc |
||
| 58 | */ |
||
| 59 | public function validate(ValidatorInterface $v, string $field, $value): bool |
||
| 60 | { |
||
| 61 | return $this->checker->check($v, $this->method, $field, $value, $this->args); |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @inheritdoc |
||
| 66 | */ |
||
| 67 | public function getMessage(string $field, $value): string |
||
| 77 | } |
||
| 78 | } |
||
| 79 |