| Conditions | 1 |
| Paths | 1 |
| Total Lines | 125 |
| Code Lines | 45 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 |
||
| 154 | public function predefinedSchemaProvider() |
||
| 155 | { |
||
| 156 | return [ |
||
| 157 | [ |
||
| 158 | '{ __type { name } }', |
||
| 159 | [ |
||
| 160 | 'errors' => [['message' => 'Require "name" arguments to query "__type"']] |
||
| 161 | ] |
||
| 162 | ], |
||
| 163 | [ |
||
| 164 | '{ __type (name: "__Type") { name } }', |
||
| 165 | [ |
||
| 166 | 'data' => [ |
||
| 167 | '__type' => ['name' => '__Type'] |
||
| 168 | ] |
||
| 169 | ] |
||
| 170 | ], |
||
| 171 | [ |
||
| 172 | '{ __type (name: "InvalidName") { name } }', |
||
| 173 | [ |
||
| 174 | 'data' => [ |
||
| 175 | '__type' => null |
||
| 176 | ] |
||
| 177 | ] |
||
| 178 | ], |
||
| 179 | [ |
||
| 180 | '{ |
||
| 181 | __schema { |
||
| 182 | types { |
||
| 183 | name, |
||
| 184 | fields { |
||
| 185 | name |
||
| 186 | } |
||
| 187 | } |
||
| 188 | } |
||
| 189 | }', |
||
| 190 | [ |
||
| 191 | 'data' => [ |
||
| 192 | '__schema' => [ |
||
| 193 | 'types' => [ |
||
| 194 | ['name' => 'TestSchemaQuery', 'fields' => [['name' => 'latest']]], |
||
| 195 | ['name' => 'Int', 'fields' => null], |
||
| 196 | ['name' => 'LatestType', 'fields' => [['name' => 'id'], ['name' => 'name']]], |
||
| 197 | ['name' => 'String', 'fields' => null], |
||
| 198 | ['name' => '__Schema', 'fields' => [['name' => 'queryType'], ['name' => 'mutationType'], ['name' => 'subscriptionType'], ['name' => 'types'], ['name' => 'directives']]], |
||
| 199 | ['name' => '__Type', 'fields' => [['name' => 'name'], ['name' => 'kind'], ['name' => 'description'], ['name' => 'ofType'], ['name' => 'inputFields'], ['name' => 'enumValues'], ['name' => 'fields'], ['name' => 'interfaces'], ['name' => 'possibleTypes']]], |
||
| 200 | ['name' => '__InputValue', 'fields' => [['name' => 'name'], ['name' => 'description'], ['name' => 'type'], ['name' => 'defaultValue'],]], |
||
| 201 | ['name' => '__EnumValue', 'fields' => [['name' => 'name'], ['name' => 'description'], ['name' => 'deprecationReason'], ['name' => 'isDeprecated'],]], |
||
| 202 | ['name' => 'Boolean', 'fields' => null], |
||
| 203 | ['name' => '__Field', 'fields' => [['name' => 'name'], ['name' => 'description'], ['name' => 'isDeprecated'], ['name' => 'deprecationReason'], ['name' => 'type'], ['name' => 'args']]], |
||
| 204 | ['name' => '__Subscription', 'fields' => [['name' => 'name']]], |
||
| 205 | ['name' => '__Directive', 'fields' => [['name' => 'name'], ['name' => 'description'], ['name' => 'args'], ['name' => 'onOperation'], ['name' => 'onFragment'], ['name' => 'onField']]], |
||
| 206 | ] |
||
| 207 | ] |
||
| 208 | ] |
||
| 209 | ] |
||
| 210 | ], |
||
| 211 | [ |
||
| 212 | '{ |
||
| 213 | test : __schema { |
||
| 214 | queryType { |
||
| 215 | kind, |
||
| 216 | name, |
||
| 217 | fields { |
||
| 218 | name, |
||
| 219 | isDeprecated, |
||
| 220 | deprecationReason, |
||
| 221 | description, |
||
| 222 | type { |
||
| 223 | name |
||
| 224 | } |
||
| 225 | } |
||
| 226 | } |
||
| 227 | } |
||
| 228 | }', |
||
| 229 | ['data' => [ |
||
| 230 | 'test' => [ |
||
| 231 | 'queryType' => [ |
||
| 232 | 'name' => 'TestSchemaQuery', |
||
| 233 | 'kind' => 'OBJECT', |
||
| 234 | 'fields' => [ |
||
| 235 | ['name' => 'latest', 'isDeprecated' => true, 'deprecationReason' => 'for test', 'description' => 'latest description', 'type' => ['name' => 'LatestType']] |
||
| 236 | ] |
||
| 237 | ] |
||
| 238 | ] |
||
| 239 | ]] |
||
| 240 | ], |
||
| 241 | [ |
||
| 242 | '{ |
||
| 243 | __schema { |
||
| 244 | queryType { |
||
| 245 | kind, |
||
| 246 | name, |
||
| 247 | description, |
||
| 248 | interfaces { |
||
| 249 | name |
||
| 250 | }, |
||
| 251 | possibleTypes { |
||
| 252 | name |
||
| 253 | }, |
||
| 254 | inputFields { |
||
| 255 | name |
||
| 256 | }, |
||
| 257 | ofType{ |
||
| 258 | name |
||
| 259 | } |
||
| 260 | } |
||
| 261 | } |
||
| 262 | }', |
||
| 263 | ['data' => [ |
||
| 264 | '__schema' => [ |
||
| 265 | 'queryType' => [ |
||
| 266 | 'kind' => 'OBJECT', |
||
| 267 | 'name' => 'TestSchemaQuery', |
||
| 268 | 'description' => null, |
||
| 269 | 'interfaces' => [], |
||
| 270 | 'possibleTypes' => null, |
||
| 271 | 'inputFields' => null, |
||
| 272 | 'ofType' => null |
||
| 273 | ] |
||
| 274 | ] |
||
| 275 | ]] |
||
| 276 | ] |
||
| 277 | ]; |
||
| 278 | } |
||
| 279 | |||
| 370 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.