| Conditions | 1 |
| Paths | 1 |
| Total Lines | 141 |
| Code Lines | 127 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 1 | Features | 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 |
||
| 120 | public static function setUpProperties($properties, JsonBasicSchema $ownerSchema) |
||
| 121 | { |
||
| 122 | $properties->id = JsonBasicSchema::string(); |
||
| 123 | $properties->id->format = 'uri'; |
||
| 124 | $properties->schema = JsonBasicSchema::string(); |
||
| 125 | $properties->schema->format = 'uri'; |
||
| 126 | $ownerSchema->addPropertyMapping('$schema', self::names()->schema); |
||
|
|
|||
| 127 | $properties->title = JsonBasicSchema::string(); |
||
| 128 | $properties->description = JsonBasicSchema::string(); |
||
| 129 | $properties->default = new JsonBasicSchema(); |
||
| 130 | $properties->multipleOf = JsonBasicSchema::number(); |
||
| 131 | $properties->multipleOf->minimum = 0; |
||
| 132 | $properties->multipleOf->exclusiveMinimum = true; |
||
| 133 | $properties->maximum = JsonBasicSchema::number(); |
||
| 134 | $properties->exclusiveMaximum = JsonBasicSchema::boolean(); |
||
| 135 | $properties->exclusiveMaximum->default = false; |
||
| 136 | $properties->minimum = JsonBasicSchema::number(); |
||
| 137 | $properties->exclusiveMinimum = JsonBasicSchema::boolean(); |
||
| 138 | $properties->exclusiveMinimum->default = false; |
||
| 139 | $properties->maxLength = JsonBasicSchema::integer(); |
||
| 140 | $properties->maxLength->minimum = 0; |
||
| 141 | $properties->minLength = new JsonBasicSchema(); |
||
| 142 | $properties->minLength->allOf[0] = JsonBasicSchema::integer(); |
||
| 143 | $properties->minLength->allOf[0]->minimum = 0; |
||
| 144 | $properties->minLength->allOf[1] = new JsonBasicSchema(); |
||
| 145 | $properties->minLength->allOf[1]->default = 0; |
||
| 146 | $properties->pattern = JsonBasicSchema::string(); |
||
| 147 | $properties->pattern->format = 'regex'; |
||
| 148 | $properties->additionalItems = new JsonBasicSchema(); |
||
| 149 | $properties->additionalItems->anyOf[0] = JsonBasicSchema::boolean(); |
||
| 150 | $properties->additionalItems->anyOf[1] = JsonBasicSchema::schema(); |
||
| 151 | $properties->additionalItems->default = (object)array ( |
||
| 152 | ); |
||
| 153 | $properties->items = new JsonBasicSchema(); |
||
| 154 | $properties->items->anyOf[0] = JsonBasicSchema::schema(); |
||
| 155 | $properties->items->anyOf[1] = JsonBasicSchema::arr(); |
||
| 156 | $properties->items->anyOf[1]->items = JsonBasicSchema::schema(); |
||
| 157 | $properties->items->anyOf[1]->minItems = 1; |
||
| 158 | $properties->items->default = (object)array ( |
||
| 159 | ); |
||
| 160 | $properties->maxItems = JsonBasicSchema::integer(); |
||
| 161 | $properties->maxItems->minimum = 0; |
||
| 162 | $properties->minItems = new JsonBasicSchema(); |
||
| 163 | $properties->minItems->allOf[0] = JsonBasicSchema::integer(); |
||
| 164 | $properties->minItems->allOf[0]->minimum = 0; |
||
| 165 | $properties->minItems->allOf[1] = new JsonBasicSchema(); |
||
| 166 | $properties->minItems->allOf[1]->default = 0; |
||
| 167 | $properties->uniqueItems = JsonBasicSchema::boolean(); |
||
| 168 | $properties->uniqueItems->default = false; |
||
| 169 | $properties->maxProperties = JsonBasicSchema::integer(); |
||
| 170 | $properties->maxProperties->minimum = 0; |
||
| 171 | $properties->minProperties = new JsonBasicSchema(); |
||
| 172 | $properties->minProperties->allOf[0] = JsonBasicSchema::integer(); |
||
| 173 | $properties->minProperties->allOf[0]->minimum = 0; |
||
| 174 | $properties->minProperties->allOf[1] = new JsonBasicSchema(); |
||
| 175 | $properties->minProperties->allOf[1]->default = 0; |
||
| 176 | $properties->required = JsonBasicSchema::arr(); |
||
| 177 | $properties->required->items = JsonBasicSchema::string(); |
||
| 178 | $properties->required->minItems = 1; |
||
| 179 | $properties->required->uniqueItems = true; |
||
| 180 | $properties->additionalProperties = new JsonBasicSchema(); |
||
| 181 | $properties->additionalProperties->anyOf[0] = JsonBasicSchema::boolean(); |
||
| 182 | $properties->additionalProperties->anyOf[1] = JsonBasicSchema::schema(); |
||
| 183 | $properties->additionalProperties->default = (object)array ( |
||
| 184 | ); |
||
| 185 | $properties->definitions = JsonBasicSchema::object(); |
||
| 186 | $properties->definitions->additionalProperties = JsonBasicSchema::schema(); |
||
| 187 | $properties->definitions->default = (object)array ( |
||
| 188 | ); |
||
| 189 | $properties->properties = JsonBasicSchema::object(); |
||
| 190 | $properties->properties->additionalProperties = JsonBasicSchema::schema(); |
||
| 191 | $properties->properties->default = (object)array ( |
||
| 192 | ); |
||
| 193 | $properties->patternProperties = JsonBasicSchema::object(); |
||
| 194 | $properties->patternProperties->additionalProperties = JsonBasicSchema::schema(); |
||
| 195 | $properties->patternProperties->default = (object)array ( |
||
| 196 | ); |
||
| 197 | $properties->dependencies = JsonBasicSchema::object(); |
||
| 198 | $properties->dependencies->additionalProperties = new JsonBasicSchema(); |
||
| 199 | $properties->dependencies->additionalProperties->anyOf[0] = JsonBasicSchema::schema(); |
||
| 200 | $properties->dependencies->additionalProperties->anyOf[1] = JsonBasicSchema::arr(); |
||
| 201 | $properties->dependencies->additionalProperties->anyOf[1]->items = JsonBasicSchema::string(); |
||
| 202 | $properties->dependencies->additionalProperties->anyOf[1]->minItems = 1; |
||
| 203 | $properties->dependencies->additionalProperties->anyOf[1]->uniqueItems = true; |
||
| 204 | $properties->enum = JsonBasicSchema::arr(); |
||
| 205 | $properties->enum->minItems = 1; |
||
| 206 | $properties->enum->uniqueItems = true; |
||
| 207 | $properties->type = new JsonBasicSchema(); |
||
| 208 | $properties->type->anyOf[0] = new JsonBasicSchema(); |
||
| 209 | $properties->type->anyOf[0]->enum = array ( |
||
| 210 | 0 => 'array', |
||
| 211 | 1 => 'boolean', |
||
| 212 | 2 => 'integer', |
||
| 213 | 3 => 'null', |
||
| 214 | 4 => 'number', |
||
| 215 | 5 => 'object', |
||
| 216 | 6 => 'string', |
||
| 217 | ); |
||
| 218 | $properties->type->anyOf[1] = JsonBasicSchema::arr(); |
||
| 219 | $properties->type->anyOf[1]->items = new JsonBasicSchema(); |
||
| 220 | $properties->type->anyOf[1]->items->enum = array ( |
||
| 221 | 0 => 'array', |
||
| 222 | 1 => 'boolean', |
||
| 223 | 2 => 'integer', |
||
| 224 | 3 => 'null', |
||
| 225 | 4 => 'number', |
||
| 226 | 5 => 'object', |
||
| 227 | 6 => 'string', |
||
| 228 | ); |
||
| 229 | $properties->type->anyOf[1]->minItems = 1; |
||
| 230 | $properties->type->anyOf[1]->uniqueItems = true; |
||
| 231 | $properties->format = JsonBasicSchema::string(); |
||
| 232 | $properties->ref = JsonBasicSchema::string(); |
||
| 233 | $ownerSchema->addPropertyMapping('$ref', self::names()->ref); |
||
| 234 | $properties->allOf = JsonBasicSchema::arr(); |
||
| 235 | $properties->allOf->items = JsonBasicSchema::schema(); |
||
| 236 | $properties->allOf->minItems = 1; |
||
| 237 | $properties->anyOf = JsonBasicSchema::arr(); |
||
| 238 | $properties->anyOf->items = JsonBasicSchema::schema(); |
||
| 239 | $properties->anyOf->minItems = 1; |
||
| 240 | $properties->oneOf = JsonBasicSchema::arr(); |
||
| 241 | $properties->oneOf->items = JsonBasicSchema::schema(); |
||
| 242 | $properties->oneOf->minItems = 1; |
||
| 243 | $properties->not = JsonBasicSchema::schema(); |
||
| 244 | $ownerSchema->type = 'object'; |
||
| 245 | $ownerSchema->id = 'http://json-schema.org/draft-04/schema#'; |
||
| 246 | $ownerSchema->schema = 'http://json-schema.org/draft-04/schema#'; |
||
| 247 | $ownerSchema->description = 'Core schema meta-schema'; |
||
| 248 | $ownerSchema->default = (object)array ( |
||
| 249 | ); |
||
| 250 | $ownerSchema->dependencies = (object)array ( |
||
| 251 | 'exclusiveMaximum' => |
||
| 252 | array ( |
||
| 253 | 0 => 'maximum', |
||
| 254 | ), |
||
| 255 | 'exclusiveMinimum' => |
||
| 256 | array ( |
||
| 257 | 0 => 'minimum', |
||
| 258 | ), |
||
| 259 | ); |
||
| 260 | } |
||
| 261 | |||
| 603 |
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@propertyannotation 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.