Conditions | 1 |
Paths | 1 |
Total Lines | 80 |
Code Lines | 75 |
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 |
||
55 | public static function setUpProperties($properties, JsonBasicSchema $ownerSchema) |
||
56 | { |
||
57 | $properties->tags = JsonBasicSchema::arr(); |
||
58 | $properties->tags->items = JsonBasicSchema::string(); |
||
59 | $properties->tags->uniqueItems = true; |
||
60 | $properties->summary = JsonBasicSchema::string(); |
||
61 | $properties->summary->description = 'A brief summary of the operation.'; |
||
|
|||
62 | $properties->description = JsonBasicSchema::string(); |
||
63 | $properties->description->description = 'A longer description of the operation, GitHub Flavored Markdown is allowed.'; |
||
64 | $properties->externalDocs = ExternalDocs::schema(); |
||
65 | $properties->operationId = JsonBasicSchema::string(); |
||
66 | $properties->operationId->description = 'A unique identifier of the operation.'; |
||
67 | $properties->produces = new JsonBasicSchema(); |
||
68 | $properties->produces->allOf[0] = JsonBasicSchema::arr(); |
||
69 | $properties->produces->allOf[0]->items = JsonBasicSchema::string(); |
||
70 | $properties->produces->allOf[0]->items->description = 'The MIME type of the HTTP message.'; |
||
71 | $properties->produces->allOf[0]->uniqueItems = true; |
||
72 | $properties->produces->description = 'A list of MIME types the API can produce.'; |
||
73 | $properties->consumes = new JsonBasicSchema(); |
||
74 | $properties->consumes->allOf[0] = JsonBasicSchema::arr(); |
||
75 | $properties->consumes->allOf[0]->items = JsonBasicSchema::string(); |
||
76 | $properties->consumes->allOf[0]->items->description = 'The MIME type of the HTTP message.'; |
||
77 | $properties->consumes->allOf[0]->uniqueItems = true; |
||
78 | $properties->consumes->description = 'A list of MIME types the API can consume.'; |
||
79 | $properties->parameters = JsonBasicSchema::arr(); |
||
80 | $properties->parameters->items = new JsonBasicSchema(); |
||
81 | $properties->parameters->items->oneOf[0] = new JsonBasicSchema(); |
||
82 | $properties->parameters->items->oneOf[0]->oneOf[0] = BodyParameter::schema(); |
||
83 | $properties->parameters->items->oneOf[0]->oneOf[1] = JsonBasicSchema::object(); |
||
84 | $properties->parameters->items->oneOf[0]->oneOf[1]->oneOf[0] = HeaderParameterSubSchema::schema(); |
||
85 | $properties->parameters->items->oneOf[0]->oneOf[1]->oneOf[1] = FormDataParameterSubSchema::schema(); |
||
86 | $properties->parameters->items->oneOf[0]->oneOf[1]->oneOf[2] = QueryParameterSubSchema::schema(); |
||
87 | $properties->parameters->items->oneOf[0]->oneOf[1]->oneOf[3] = PathParameterSubSchema::schema(); |
||
88 | $properties->parameters->items->oneOf[0]->oneOf[1]->required = array ( |
||
89 | 0 => 'name', |
||
90 | 1 => 'in', |
||
91 | 2 => 'type', |
||
92 | ); |
||
93 | $properties->parameters->items->oneOf[1] = JsonReference::schema(); |
||
94 | $properties->parameters->description = 'The parameters needed to send a valid API call.'; |
||
95 | $properties->parameters->uniqueItems = true; |
||
96 | $properties->responses = JsonBasicSchema::object(); |
||
97 | $properties->responses->additionalProperties = false; |
||
98 | $properties->responses->patternProperties['^([0-9]{3})$|^(default)$'] = new JsonBasicSchema(); |
||
99 | $properties->responses->patternProperties['^([0-9]{3})$|^(default)$']->oneOf[0] = Response::schema(); |
||
100 | $properties->responses->patternProperties['^([0-9]{3})$|^(default)$']->oneOf[1] = JsonReference::schema(); |
||
101 | $properties->responses->patternProperties['^x-'] = new JsonBasicSchema(); |
||
102 | $properties->responses->patternProperties['^x-']->description = 'Any property starting with x- is valid.'; |
||
103 | $properties->responses->not = JsonBasicSchema::object(); |
||
104 | $properties->responses->not->additionalProperties = false; |
||
105 | $properties->responses->not->patternProperties['^x-'] = new JsonBasicSchema(); |
||
106 | $properties->responses->not->patternProperties['^x-']->description = 'Any property starting with x- is valid.'; |
||
107 | $properties->responses->description = 'Response objects names can either be any valid HTTP status code or \'default\'.'; |
||
108 | $properties->responses->minProperties = 1; |
||
109 | $properties->schemes = JsonBasicSchema::arr(); |
||
110 | $properties->schemes->items = JsonBasicSchema::string(); |
||
111 | $properties->schemes->items->enum = array ( |
||
112 | 0 => 'http', |
||
113 | 1 => 'https', |
||
114 | 2 => 'ws', |
||
115 | 3 => 'wss', |
||
116 | ); |
||
117 | $properties->schemes->description = 'The transfer protocol of the API.'; |
||
118 | $properties->schemes->uniqueItems = true; |
||
119 | $properties->deprecated = JsonBasicSchema::boolean(); |
||
120 | $properties->deprecated->default = false; |
||
121 | $properties->security = JsonBasicSchema::arr(); |
||
122 | $properties->security->items = JsonBasicSchema::object(); |
||
123 | $properties->security->items->additionalProperties = JsonBasicSchema::arr(); |
||
124 | $properties->security->items->additionalProperties->items = JsonBasicSchema::string(); |
||
125 | $properties->security->items->additionalProperties->uniqueItems = true; |
||
126 | $properties->security->uniqueItems = true; |
||
127 | $ownerSchema->type = 'object'; |
||
128 | $ownerSchema->additionalProperties = false; |
||
129 | $ownerSchema->patternProperties['^x-'] = new JsonBasicSchema(); |
||
130 | $ownerSchema->patternProperties['^x-']->description = 'Any property starting with x- is valid.'; |
||
131 | $ownerSchema->required = array ( |
||
132 | 0 => 'responses', |
||
133 | ); |
||
134 | } |
||
135 | } |
||
137 |
Since your code implements the magic setter
_set
, this function will be called for any write access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write 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.