1 | <?php |
||
30 | class Properties extends ValidatorAnnotation |
||
31 | { |
||
32 | public $properties = []; |
||
33 | public $patternProperties = []; |
||
34 | public $additionalProperties; |
||
35 | |||
36 | 80 | public function __construct() |
|
37 | { |
||
38 | 80 | parent::__construct(PropertiesValidator::class); |
|
39 | 80 | } |
|
40 | |||
41 | 80 | public function getValue() |
|
42 | { |
||
43 | return [ |
||
44 | 80 | 'properties' => $this->getPropertiesConfigFor($this->properties), |
|
45 | 79 | 'patternProperties' => $this->getPropertiesConfigFor($this->patternProperties), |
|
46 | 79 | 'additionalProperties' => $this->additionalProperties, |
|
47 | 79 | ]; |
|
48 | } |
||
49 | |||
50 | 80 | private function getPropertiesConfigFor(array $data) |
|
51 | { |
||
52 | 80 | $count = count($data); |
|
53 | 80 | $this->validatePropertiesCountOrThrowException($count); |
|
54 | 79 | $properties = array(); |
|
55 | 79 | for ($i = 0; $i < $count; $i += 2) { |
|
56 | 79 | $properties[$data[$i]] = $data[$i + 1]; |
|
57 | 79 | } |
|
58 | 79 | return $properties; |
|
59 | } |
||
60 | |||
61 | 80 | private function validatePropertiesCountOrThrowException($count) |
|
69 | } |
||
70 |