Total Complexity | 6 |
Total Lines | 41 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | final class ValidatorCollector implements SummaryCollectorInterface |
||
13 | { |
||
14 | use CollectorTrait; |
||
15 | |||
16 | private array $validations = []; |
||
17 | |||
18 | public function getCollected(): array |
||
19 | { |
||
20 | return $this->validations; |
||
21 | } |
||
22 | |||
23 | public function collect(mixed $value, Result $result, ?iterable $rules = null): void |
||
24 | { |
||
25 | if (!$this->isActive()) { |
||
26 | return; |
||
27 | } |
||
28 | |||
29 | $this->validations[] = [ |
||
30 | 'value' => $value, |
||
31 | 'rules' => $rules instanceof Traversable ? iterator_to_array($rules, true) : (array) $rules, |
||
32 | 'result' => $result->isValid(), |
||
33 | 'errors' => $result->getErrors(), |
||
34 | ]; |
||
35 | } |
||
36 | |||
37 | private function reset(): void |
||
|
|||
38 | { |
||
39 | $this->validations = []; |
||
40 | } |
||
41 | |||
42 | public function getSummary(): array |
||
53 | ], |
||
54 | ]; |
||
55 | } |
||
56 | } |
||
57 |
This check looks for private methods that have been defined, but are not used inside the class.