Conditions | 1 |
Paths | 1 |
Total Lines | 93 |
Code Lines | 87 |
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 |
||
64 | public static function setUpProperties($properties, Schema1 $ownerSchema) |
||
65 | { |
||
66 | $properties->swagger = Schema1::string(); |
||
67 | $properties->swagger->description = 'The Swagger version of this document.'; |
||
|
|||
68 | $properties->swagger->enum = array ( |
||
69 | 0 => '2.0', |
||
70 | ); |
||
71 | $properties->info = Info::schema(); |
||
72 | $properties->host = Schema1::string(); |
||
73 | $properties->host->description = 'The host (name or ip) of the API. Example: \'swagger.io\''; |
||
74 | $properties->host->pattern = '^[^{}/ :\\\\]+(?::\\d+)?$'; |
||
75 | $properties->basePath = Schema1::string(); |
||
76 | $properties->basePath->description = 'The base path to the API. Example: \'/api\'.'; |
||
77 | $properties->basePath->pattern = '^/'; |
||
78 | $properties->schemes = Schema1::arr(); |
||
79 | $properties->schemes->items = Schema1::string(); |
||
80 | $properties->schemes->items->enum = array ( |
||
81 | 0 => 'http', |
||
82 | 1 => 'https', |
||
83 | 2 => 'ws', |
||
84 | 3 => 'wss', |
||
85 | ); |
||
86 | $properties->schemes->description = 'The transfer protocol of the API.'; |
||
87 | $properties->schemes->uniqueItems = true; |
||
88 | $properties->consumes = new Schema1(); |
||
89 | $properties->consumes->allOf[0] = Schema1::arr(); |
||
90 | $properties->consumes->allOf[0]->items = Schema1::string(); |
||
91 | $properties->consumes->allOf[0]->items->description = 'The MIME type of the HTTP message.'; |
||
92 | $properties->consumes->allOf[0]->uniqueItems = true; |
||
93 | $properties->consumes->description = 'A list of MIME types accepted by the API.'; |
||
94 | $properties->produces = new Schema1(); |
||
95 | $properties->produces->allOf[0] = Schema1::arr(); |
||
96 | $properties->produces->allOf[0]->items = Schema1::string(); |
||
97 | $properties->produces->allOf[0]->items->description = 'The MIME type of the HTTP message.'; |
||
98 | $properties->produces->allOf[0]->uniqueItems = true; |
||
99 | $properties->produces->description = 'A list of MIME types the API can produce.'; |
||
100 | $properties->paths = Schema1::object(); |
||
101 | $properties->paths->additionalProperties = false; |
||
102 | $properties->paths->patternProperties['^x-'] = new Schema1(); |
||
103 | $properties->paths->patternProperties['^x-']->description = 'Any property starting with x- is valid.'; |
||
104 | $properties->paths->patternProperties['^/'] = PathItem::schema(); |
||
105 | $properties->paths->description = 'Relative paths to the individual endpoints. They must be relative to the \'basePath\'.'; |
||
106 | $properties->definitions = Schema1::object(); |
||
107 | $properties->definitions->additionalProperties = Schema::schema(); |
||
108 | $properties->definitions->description = 'One or more JSON objects describing the schemas being consumed and produced by the API.'; |
||
109 | $properties->parameters = Schema1::object(); |
||
110 | $properties->parameters->additionalProperties = new Schema1(); |
||
111 | $properties->parameters->additionalProperties->oneOf[0] = BodyParameter::schema(); |
||
112 | $properties->parameters->additionalProperties->oneOf[1] = Schema1::object(); |
||
113 | $properties->parameters->additionalProperties->oneOf[1]->oneOf[0] = HeaderParameterSubSchema::schema(); |
||
114 | $properties->parameters->additionalProperties->oneOf[1]->oneOf[1] = FormDataParameterSubSchema::schema(); |
||
115 | $properties->parameters->additionalProperties->oneOf[1]->oneOf[2] = QueryParameterSubSchema::schema(); |
||
116 | $properties->parameters->additionalProperties->oneOf[1]->oneOf[3] = PathParameterSubSchema::schema(); |
||
117 | $properties->parameters->additionalProperties->oneOf[1]->required = array ( |
||
118 | 0 => 'name', |
||
119 | 1 => 'in', |
||
120 | 2 => 'type', |
||
121 | ); |
||
122 | $properties->parameters->description = 'One or more JSON representations for parameters'; |
||
123 | $properties->responses = Schema1::object(); |
||
124 | $properties->responses->additionalProperties = Response::schema(); |
||
125 | $properties->responses->description = 'One or more JSON representations for parameters'; |
||
126 | $properties->security = Schema1::arr(); |
||
127 | $properties->security->items = Schema1::object(); |
||
128 | $properties->security->items->additionalProperties = Schema1::arr(); |
||
129 | $properties->security->items->additionalProperties->items = Schema1::string(); |
||
130 | $properties->security->items->additionalProperties->uniqueItems = true; |
||
131 | $properties->security->uniqueItems = true; |
||
132 | $properties->securityDefinitions = Schema1::object(); |
||
133 | $properties->securityDefinitions->additionalProperties = new Schema1(); |
||
134 | $properties->securityDefinitions->additionalProperties->oneOf[0] = BasicAuthenticationSecurity::schema(); |
||
135 | $properties->securityDefinitions->additionalProperties->oneOf[1] = ApiKeySecurity::schema(); |
||
136 | $properties->securityDefinitions->additionalProperties->oneOf[2] = Oauth2ImplicitSecurity::schema(); |
||
137 | $properties->securityDefinitions->additionalProperties->oneOf[3] = Oauth2PasswordSecurity::schema(); |
||
138 | $properties->securityDefinitions->additionalProperties->oneOf[4] = Oauth2ApplicationSecurity::schema(); |
||
139 | $properties->securityDefinitions->additionalProperties->oneOf[5] = Oauth2AccessCodeSecurity::schema(); |
||
140 | $properties->tags = Schema1::arr(); |
||
141 | $properties->tags->items = Tag::schema(); |
||
142 | $properties->tags->uniqueItems = true; |
||
143 | $properties->externalDocs = ExternalDocs::schema(); |
||
144 | $ownerSchema->type = 'object'; |
||
145 | $ownerSchema->additionalProperties = false; |
||
146 | $ownerSchema->patternProperties['^x-'] = new Schema1(); |
||
147 | $ownerSchema->patternProperties['^x-']->description = 'Any property starting with x- is valid.'; |
||
148 | $ownerSchema->id = 'http://swagger.io/v2/schema.json#'; |
||
149 | $ownerSchema->schema = 'http://json-schema.org/draft-04/schema#'; |
||
150 | $ownerSchema->title = 'A JSON Schema for Swagger 2.0 API.'; |
||
151 | $ownerSchema->required = array ( |
||
152 | 0 => 'swagger', |
||
153 | 1 => 'info', |
||
154 | 2 => 'paths', |
||
155 | ); |
||
156 | } |
||
157 | } |
||
159 |
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.