| Total Complexity | 12 |
| 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 AbstractSpecification[] $validators |
||
| 21 | * |
||
| 22 | * @return $this |
||
| 23 | */ |
||
| 24 | public function setValidators(array $validators) |
||
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @param AbstractSpecification $validator |
||
| 37 | * |
||
| 38 | * @return $this |
||
| 39 | * @internal param string $claim |
||
| 40 | */ |
||
| 41 | public function addValidator(AbstractSpecification $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 | * @throws \OutOfBoundsException |
||
| 54 | */ |
||
| 55 | public function validate(array $data, Token $token) |
||
| 56 | { |
||
| 57 | $valid = true; |
||
| 58 | foreach ($this->validators as $claim => $validator) { |
||
| 59 | if ($token->hasClaim($claim) === false) { |
||
| 60 | if ($validator->isRequired()) { |
||
| 61 | $valid = false; |
||
| 62 | $this->messages[$claim] = sprintf('Missing required value for claim %s', $claim); |
||
| 63 | } |
||
| 64 | } else { |
||
| 65 | if (isset($data[$claim]) && !$validator->isSatisfiedBy($data[$claim], $token->getClaim($claim))) { |
||
| 66 | $valid = false; |
||
| 67 | $this->messages[$claim] = $validator->getMessage(); |
||
| 68 | } |
||
| 69 | } |
||
| 70 | } |
||
| 71 | |||
| 72 | return $valid; |
||
| 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 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths