Conditions | 1 |
Paths | 1 |
Total Lines | 68 |
Code Lines | 63 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | 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 |
||
81 | public static function setUpProperties($properties, JsonBasicSchema $ownerSchema) |
||
82 | { |
||
83 | $properties->required = JsonBasicSchema::boolean(); |
||
84 | $properties->required->description = 'Determines whether or not this parameter is required or optional.'; |
||
85 | $properties->required->default = false; |
||
86 | $properties->in = JsonBasicSchema::string(); |
||
87 | $properties->in->description = 'Determines the location of the parameter.'; |
||
88 | $properties->in->enum = array ( |
||
89 | 0 => 'header', |
||
90 | ); |
||
91 | $properties->description = JsonBasicSchema::string(); |
||
92 | $properties->description->description = 'A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed.'; |
||
93 | $properties->name = JsonBasicSchema::string(); |
||
94 | $properties->name->description = 'The name of the parameter.'; |
||
95 | $properties->type = JsonBasicSchema::string(); |
||
96 | $properties->type->enum = array ( |
||
97 | 0 => 'string', |
||
98 | 1 => 'number', |
||
99 | 2 => 'boolean', |
||
100 | 3 => 'integer', |
||
101 | 4 => 'array', |
||
102 | ); |
||
103 | $properties->format = JsonBasicSchema::string(); |
||
104 | $properties->items = PrimitivesItems::schema(); |
||
105 | $properties->collectionFormat = JsonBasicSchema::string(); |
||
106 | $properties->collectionFormat->default = 'csv'; |
||
107 | $properties->collectionFormat->enum = array ( |
||
108 | 0 => 'csv', |
||
109 | 1 => 'ssv', |
||
110 | 2 => 'tsv', |
||
111 | 3 => 'pipes', |
||
112 | ); |
||
113 | $properties->default = new JsonBasicSchema(); |
||
114 | $properties->maximum = JsonBasicSchema::number(); |
||
115 | $properties->exclusiveMaximum = JsonBasicSchema::boolean(); |
||
116 | $properties->exclusiveMaximum->default = false; |
||
117 | $properties->minimum = JsonBasicSchema::number(); |
||
118 | $properties->exclusiveMinimum = JsonBasicSchema::boolean(); |
||
119 | $properties->exclusiveMinimum->default = false; |
||
120 | $properties->maxLength = JsonBasicSchema::integer(); |
||
121 | $properties->maxLength->minimum = 0; |
||
|
|||
122 | $properties->minLength = new JsonBasicSchema(); |
||
123 | $properties->minLength->allOf[0] = JsonBasicSchema::integer(); |
||
124 | $properties->minLength->allOf[0]->minimum = 0; |
||
125 | $properties->minLength->allOf[1] = new JsonBasicSchema(); |
||
126 | $properties->minLength->allOf[1]->default = 0; |
||
127 | $properties->pattern = JsonBasicSchema::string(); |
||
128 | $properties->pattern->format = 'regex'; |
||
129 | $properties->maxItems = JsonBasicSchema::integer(); |
||
130 | $properties->maxItems->minimum = 0; |
||
131 | $properties->minItems = new JsonBasicSchema(); |
||
132 | $properties->minItems->allOf[0] = JsonBasicSchema::integer(); |
||
133 | $properties->minItems->allOf[0]->minimum = 0; |
||
134 | $properties->minItems->allOf[1] = new JsonBasicSchema(); |
||
135 | $properties->minItems->allOf[1]->default = 0; |
||
136 | $properties->uniqueItems = JsonBasicSchema::boolean(); |
||
137 | $properties->uniqueItems->default = false; |
||
138 | $properties->enum = JsonBasicSchema::arr(); |
||
139 | $properties->enum->minItems = 1; |
||
140 | $properties->enum->uniqueItems = true; |
||
141 | $properties->multipleOf = JsonBasicSchema::number(); |
||
142 | $properties->multipleOf->minimum = 0; |
||
143 | $properties->multipleOf->exclusiveMinimum = true; |
||
144 | $ownerSchema = new JsonBasicSchema(); |
||
145 | $ownerSchema->additionalProperties = false; |
||
146 | $ownerSchema->patternProperties['^x-'] = new JsonBasicSchema(); |
||
147 | $ownerSchema->patternProperties['^x-']->description = 'Any property starting with x- is valid.'; |
||
148 | } |
||
149 | |||
361 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.