1 | <?php |
||
40 | class AnnotationReaderResultValidator { |
||
41 | |||
42 | /** |
||
43 | * Validates a reader result against the provided definition. |
||
44 | * @param \Brickoo\Component\Common\Collection $collection |
||
45 | * @param \Brickoo\Component\Annotation\AnnotationReaderResult $readerResult |
||
46 | * @throws \Brickoo\Component\Annotation\Exception\MissingRequiredAnnotationException |
||
47 | * @throws \Brickoo\Component\Annotation\Exception\MissingRequiredAnnotationParametersException |
||
48 | * @return void |
||
49 | */ |
||
50 | 3 | public function validate(Collection $collection, AnnotationReaderResult $readerResult) { |
|
61 | |||
62 | /** |
||
63 | * Validates the annotations definitions against the result. |
||
64 | * @param Traversable $definitions |
||
65 | * @param Traversable $results |
||
66 | * @return void |
||
67 | */ |
||
68 | 3 | private function validateAnnotations(Traversable $definitions, Traversable $results) { |
|
77 | |||
78 | /** |
||
79 | * Returns the required annotations and their parameters. |
||
80 | * @param Traversable $definitions |
||
81 | * @return array required annotations definitions |
||
82 | */ |
||
83 | 3 | private function getRequiredAnnotationsParameters(Traversable $definitions) { |
|
92 | |||
93 | /** |
||
94 | * Returns the available result annotations and their values. |
||
95 | * @param Traversable $annotationsIterator |
||
96 | * @return array annotation values |
||
97 | */ |
||
98 | 3 | private function getAnnotationsValues(Traversable $annotationsIterator) { |
|
105 | |||
106 | /** |
||
107 | * Checks if the read annotations matches the definition requirements. |
||
108 | * @param string $requiredAnnotation |
||
109 | * @param array $requiredParameters |
||
110 | * @param array $annotationsRead |
||
111 | * @throws \Brickoo\Component\Annotation\Exception\MissingRequiredAnnotationException |
||
112 | * @throws \Brickoo\Component\Annotation\Exception\MissingRequiredAnnotationParametersException |
||
113 | * @return void |
||
114 | */ |
||
115 | 3 | private function checkAnnotationRequirements($requiredAnnotation, array $requiredParameters, array $annotationsRead) { |
|
123 | |||
124 | /** |
||
125 | * Checks if the required annotation is available in the result. |
||
126 | * @param string $annotationName |
||
127 | * @param array $readAnnotations |
||
128 | * @return boolean check result |
||
129 | */ |
||
130 | 3 | private function hasRequiredAnnotation($annotationName, array $readAnnotations) { |
|
133 | |||
134 | /** |
||
135 | * Returns the missing required parameters if any. |
||
136 | * @param array $requiredParameters |
||
137 | * @param array $readParameters |
||
138 | * @return array the missing parameters |
||
139 | */ |
||
140 | 2 | private function getMissingParameters(array $requiredParameters, array $readParameters) { |
|
149 | |||
150 | } |
||
151 |