| Conditions | 1 |
| Paths | 1 |
| Total Lines | 51 |
| Code Lines | 14 |
| 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 |
||
| 187 | public function testValidationSuccess() |
||
| 188 | { |
||
| 189 | $res = GraphQL::executeQuery( |
||
| 190 | $this->schema, |
||
| 191 | Utils::nowdoc(' |
||
| 192 | mutation UpdateBook( |
||
| 193 | $bookAttributes: BookAttributes |
||
| 194 | ) { |
||
| 195 | updateBook ( |
||
| 196 | bookAttributes: $bookAttributes |
||
| 197 | ) { |
||
| 198 | valid |
||
| 199 | suberrors { |
||
| 200 | bookAttributes { |
||
| 201 | suberrors { |
||
| 202 | title { |
||
| 203 | code |
||
| 204 | msg |
||
| 205 | } |
||
| 206 | author { |
||
| 207 | code |
||
| 208 | msg |
||
| 209 | } |
||
| 210 | } |
||
| 211 | } |
||
| 212 | } |
||
| 213 | result |
||
| 214 | } |
||
| 215 | } |
||
| 216 | '), |
||
| 217 | [], |
||
| 218 | null, |
||
| 219 | [ |
||
| 220 | 'bookAttributes' => [ |
||
| 221 | 'title' => 'Dogsbody', |
||
| 222 | 'author' => 3, |
||
| 223 | ], |
||
| 224 | ] |
||
| 225 | ); |
||
| 226 | |||
| 227 | static::assertEmpty($res->errors); |
||
| 228 | static::assertEquals( |
||
| 229 | [ |
||
| 230 | 'valid' => true, |
||
| 231 | 'suberrors' => null, |
||
| 232 | 'result' => true, |
||
| 233 | ], |
||
| 234 | $res->data['updateBook'] |
||
| 235 | ); |
||
| 236 | |||
| 237 | static::assertTrue($res->data['updateBook']['valid']); |
||
| 238 | } |
||
| 240 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.