| Total Complexity | 13 |
| Total Lines | 94 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | class ValidatorChain |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * @var array |
||
| 11 | */ |
||
| 12 | protected $validators = []; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @var array |
||
| 16 | */ |
||
| 17 | protected $messages = []; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @param SpecificationInterface[] $validators |
||
| 21 | * |
||
| 22 | * @return $this |
||
| 23 | */ |
||
| 24 | public function setValidators(array $validators) |
||
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @param string $claim |
||
| 37 | * @param SpecificationInterface $validator |
||
| 38 | * |
||
| 39 | * @return $this |
||
| 40 | */ |
||
| 41 | public function addValidator(SpecificationInterface $validator) |
||
| 42 | { |
||
| 43 | $this->validators[$validator->getName()] = $validator; |
||
| 44 | |||
| 45 | return $this; |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @param array $data |
||
| 50 | * @param Token $token |
||
| 51 | * |
||
| 52 | * @return bool |
||
| 53 | */ |
||
| 54 | public function validate(array $data, Token $token) |
||
| 73 | } |
||
| 74 | |||
| 75 | /** |
||
| 76 | * @param $name |
||
| 77 | * |
||
| 78 | * @return bool |
||
| 79 | */ |
||
| 80 | public function hasValidator($name) |
||
| 81 | { |
||
| 82 | return array_key_exists($name, $this->validators); |
||
| 83 | } |
||
| 84 | |||
| 85 | /** |
||
| 86 | * @param $name |
||
| 87 | * |
||
| 88 | * @return mixed |
||
| 89 | */ |
||
| 90 | public function getValidator($name) |
||
| 91 | { |
||
| 92 | return $this->validators[$name]; |
||
| 93 | } |
||
| 94 | |||
| 95 | /** |
||
| 96 | * @return array |
||
| 97 | */ |
||
| 98 | public function getMessages() |
||
| 101 | } |
||
| 102 | } |
||
| 103 |