1 | <?php |
||
29 | class Nested implements \Caridea\Validate\Draft |
||
30 | { |
||
31 | /** |
||
32 | * @var string The operator type |
||
33 | */ |
||
34 | private $operator; |
||
35 | /** |
||
36 | * @var \Caridea\Validate\Validator Optional. A validator for nested objects. |
||
37 | */ |
||
38 | private $validator; |
||
39 | /** |
||
40 | * @var string Optional field on object that chooses rules. |
||
41 | */ |
||
42 | private $field; |
||
43 | |||
44 | /** |
||
45 | * Creates a new NestedRule. |
||
46 | * |
||
47 | * @param string $operator The operator type |
||
48 | * @param mixed|\Caridea\Validate\Validator The validator to use, or definitions to create one |
||
49 | * @param string $field Optional field on object that chooses rules |
||
50 | */ |
||
51 | 5 | protected function __construct(string $operator, $validator, string $field = null) |
|
57 | |||
58 | /** |
||
59 | * Finishes creating a rule using the parent builder. |
||
60 | * |
||
61 | * @param \Caridea\Validate\Registry $registry |
||
62 | * @return \Caridea\Validate\Rule The fully created rule |
||
63 | */ |
||
64 | 5 | public function finish(\Caridea\Validate\Registry $registry): \Caridea\Validate\Rule |
|
90 | |||
91 | /** |
||
92 | * {@inheritDoc} |
||
93 | */ |
||
94 | 8 | public function apply($value, $data = []): ?array |
|
130 | |||
131 | /** |
||
132 | * Verifies an object value against separate validator rules. |
||
133 | * |
||
134 | * @param object $ruleset The validation ruleset |
||
135 | * @return \Caridea\Validate\Rule\Nested the created rule |
||
136 | */ |
||
137 | 1 | public static function nestedObject(\stdClass $ruleset): Nested |
|
141 | |||
142 | /** |
||
143 | * Verifies an object value using one of several validators based on a field value. |
||
144 | * |
||
145 | * @param string $field The deciding field name |
||
146 | * @param object $rulesets The rulesets |
||
147 | * @return \Caridea\Validate\Rule\Nested the created rule |
||
148 | */ |
||
149 | 1 | public static function variableObject(string $field, \stdClass $rulesets): Nested |
|
153 | |||
154 | /** |
||
155 | * Verifies each entry in a list using one or more rules. |
||
156 | * |
||
157 | * @param mixed $rules The rule or rules to enforce |
||
158 | * @return \Caridea\Validate\Rule\Nested the created rule |
||
159 | */ |
||
160 | 1 | public static function listOf($rules): Nested |
|
164 | |||
165 | /** |
||
166 | * Verifies each entry in a list against separate validator rules. |
||
167 | * |
||
168 | * @param object $ruleset The validation ruleset |
||
169 | * @return \Caridea\Validate\Rule\Nested the created rule |
||
170 | */ |
||
171 | 1 | public static function listOfObjects(\stdClass $ruleset): Nested |
|
175 | |||
176 | /** |
||
177 | * Verifies each entry in a list using one of several validators based on a field value. |
||
178 | * |
||
179 | * @param string $field The deciding field name |
||
180 | * @param object $rulesets The rulesets |
||
181 | * @return \Caridea\Validate\Rule\Nested the created rule |
||
182 | */ |
||
183 | 1 | public static function listOfDifferentObjects(string $field, \stdClass $rulesets): Nested |
|
187 | } |
||
188 |
As per the PSR-2 coding standard, case statements should not be wrapped in curly braces. There is no need for braces, since each case is terminated by the next
break
.There is also the option to use a semicolon instead of a colon, this is discouraged because many programmers do not even know it works and the colon is universal between programming languages.
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.