Conditions | 1 |
Paths | 1 |
Total Lines | 141 |
Code Lines | 127 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
119 | public static function setUpProperties($properties, Schema $ownerSchema) |
||
120 | { |
||
121 | $properties->id = Schema::string(); |
||
122 | $properties->id->format = 'uri'; |
||
123 | $properties->schema = Schema::string(); |
||
124 | $properties->schema->format = 'uri'; |
||
125 | $ownerSchema->addPropertyMapping('$schema', self::names()->schema); |
||
|
|||
126 | $properties->title = Schema::string(); |
||
127 | $properties->description = Schema::string(); |
||
128 | $properties->default = new Schema(); |
||
129 | $properties->multipleOf = Schema::number(); |
||
130 | $properties->multipleOf->minimum = 0; |
||
131 | $properties->multipleOf->exclusiveMinimum = true; |
||
132 | $properties->maximum = Schema::number(); |
||
133 | $properties->exclusiveMaximum = Schema::boolean(); |
||
134 | $properties->exclusiveMaximum->default = false; |
||
135 | $properties->minimum = Schema::number(); |
||
136 | $properties->exclusiveMinimum = Schema::boolean(); |
||
137 | $properties->exclusiveMinimum->default = false; |
||
138 | $properties->maxLength = Schema::integer(); |
||
139 | $properties->maxLength->minimum = 0; |
||
140 | $properties->minLength = new Schema(); |
||
141 | $properties->minLength->allOf[0] = Schema::integer(); |
||
142 | $properties->minLength->allOf[0]->minimum = 0; |
||
143 | $properties->minLength->allOf[1] = new Schema(); |
||
144 | $properties->minLength->allOf[1]->default = 0; |
||
145 | $properties->pattern = Schema::string(); |
||
146 | $properties->pattern->format = 'regex'; |
||
147 | $properties->additionalItems = new Schema(); |
||
148 | $properties->additionalItems->anyOf[0] = Schema::boolean(); |
||
149 | $properties->additionalItems->anyOf[1] = Schema::schema(); |
||
150 | $properties->additionalItems->default = (object)array ( |
||
151 | ); |
||
152 | $properties->items = new Schema(); |
||
153 | $properties->items->anyOf[0] = Schema::schema(); |
||
154 | $properties->items->anyOf[1] = Schema::arr(); |
||
155 | $properties->items->anyOf[1]->items = Schema::schema(); |
||
156 | $properties->items->anyOf[1]->minItems = 1; |
||
157 | $properties->items->default = (object)array ( |
||
158 | ); |
||
159 | $properties->maxItems = Schema::integer(); |
||
160 | $properties->maxItems->minimum = 0; |
||
161 | $properties->minItems = new Schema(); |
||
162 | $properties->minItems->allOf[0] = Schema::integer(); |
||
163 | $properties->minItems->allOf[0]->minimum = 0; |
||
164 | $properties->minItems->allOf[1] = new Schema(); |
||
165 | $properties->minItems->allOf[1]->default = 0; |
||
166 | $properties->uniqueItems = Schema::boolean(); |
||
167 | $properties->uniqueItems->default = false; |
||
168 | $properties->maxProperties = Schema::integer(); |
||
169 | $properties->maxProperties->minimum = 0; |
||
170 | $properties->minProperties = new Schema(); |
||
171 | $properties->minProperties->allOf[0] = Schema::integer(); |
||
172 | $properties->minProperties->allOf[0]->minimum = 0; |
||
173 | $properties->minProperties->allOf[1] = new Schema(); |
||
174 | $properties->minProperties->allOf[1]->default = 0; |
||
175 | $properties->required = Schema::arr(); |
||
176 | $properties->required->items = Schema::string(); |
||
177 | $properties->required->minItems = 1; |
||
178 | $properties->required->uniqueItems = true; |
||
179 | $properties->additionalProperties = new Schema(); |
||
180 | $properties->additionalProperties->anyOf[0] = Schema::boolean(); |
||
181 | $properties->additionalProperties->anyOf[1] = Schema::schema(); |
||
182 | $properties->additionalProperties->default = (object)array ( |
||
183 | ); |
||
184 | $properties->definitions = Schema::object(); |
||
185 | $properties->definitions->additionalProperties = Schema::schema(); |
||
186 | $properties->definitions->default = (object)array ( |
||
187 | ); |
||
188 | $properties->properties = Schema::object(); |
||
189 | $properties->properties->additionalProperties = Schema::schema(); |
||
190 | $properties->properties->default = (object)array ( |
||
191 | ); |
||
192 | $properties->patternProperties = Schema::object(); |
||
193 | $properties->patternProperties->additionalProperties = Schema::schema(); |
||
194 | $properties->patternProperties->default = (object)array ( |
||
195 | ); |
||
196 | $properties->dependencies = Schema::object(); |
||
197 | $properties->dependencies->additionalProperties = new Schema(); |
||
198 | $properties->dependencies->additionalProperties->anyOf[0] = Schema::schema(); |
||
199 | $properties->dependencies->additionalProperties->anyOf[1] = Schema::arr(); |
||
200 | $properties->dependencies->additionalProperties->anyOf[1]->items = Schema::string(); |
||
201 | $properties->dependencies->additionalProperties->anyOf[1]->minItems = 1; |
||
202 | $properties->dependencies->additionalProperties->anyOf[1]->uniqueItems = true; |
||
203 | $properties->enum = Schema::arr(); |
||
204 | $properties->enum->minItems = 1; |
||
205 | $properties->enum->uniqueItems = true; |
||
206 | $properties->type = new Schema(); |
||
207 | $properties->type->anyOf[0] = new Schema(); |
||
208 | $properties->type->anyOf[0]->enum = array ( |
||
209 | 0 => 'array', |
||
210 | 1 => 'boolean', |
||
211 | 2 => 'integer', |
||
212 | 3 => 'null', |
||
213 | 4 => 'number', |
||
214 | 5 => 'object', |
||
215 | 6 => 'string', |
||
216 | ); |
||
217 | $properties->type->anyOf[1] = Schema::arr(); |
||
218 | $properties->type->anyOf[1]->items = new Schema(); |
||
219 | $properties->type->anyOf[1]->items->enum = array ( |
||
220 | 0 => 'array', |
||
221 | 1 => 'boolean', |
||
222 | 2 => 'integer', |
||
223 | 3 => 'null', |
||
224 | 4 => 'number', |
||
225 | 5 => 'object', |
||
226 | 6 => 'string', |
||
227 | ); |
||
228 | $properties->type->anyOf[1]->minItems = 1; |
||
229 | $properties->type->anyOf[1]->uniqueItems = true; |
||
230 | $properties->format = Schema::string(); |
||
231 | $properties->ref = Schema::string(); |
||
232 | $ownerSchema->addPropertyMapping('$ref', self::names()->ref); |
||
233 | $properties->allOf = Schema::arr(); |
||
234 | $properties->allOf->items = Schema::schema(); |
||
235 | $properties->allOf->minItems = 1; |
||
236 | $properties->anyOf = Schema::arr(); |
||
237 | $properties->anyOf->items = Schema::schema(); |
||
238 | $properties->anyOf->minItems = 1; |
||
239 | $properties->oneOf = Schema::arr(); |
||
240 | $properties->oneOf->items = Schema::schema(); |
||
241 | $properties->oneOf->minItems = 1; |
||
242 | $properties->not = Schema::schema(); |
||
243 | $ownerSchema->type = 'object'; |
||
244 | $ownerSchema->id = 'http://json-schema.org/draft-04/schema#'; |
||
245 | $ownerSchema->schema = 'http://json-schema.org/draft-04/schema#'; |
||
246 | $ownerSchema->description = 'Core schema meta-schema'; |
||
247 | $ownerSchema->default = (object)array ( |
||
248 | ); |
||
249 | $ownerSchema->dependencies = (object)array ( |
||
250 | 'exclusiveMaximum' => |
||
251 | array ( |
||
252 | 0 => 'maximum', |
||
253 | ), |
||
254 | 'exclusiveMinimum' => |
||
255 | array ( |
||
256 | 0 => 'minimum', |
||
257 | ), |
||
258 | ); |
||
259 | } |
||
260 | } |
||
262 |
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.