Conditions | 1 |
Paths | 1 |
Total Lines | 67 |
Code Lines | 37 |
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 |
||
33 | public function testGraphQLSchemaFromDocumentationMustBeValid(): void |
||
34 | { |
||
35 | $schema = new Schema([ |
||
36 | 'query' => new ObjectType([ |
||
37 | 'name' => 'query', |
||
38 | 'fields' => [ |
||
39 | 'users' => [ |
||
40 | 'type' => Type::listOf($this->types->getOutput(User::class)), // Use automated ObjectType for output |
||
41 | 'resolve' => function ($root, $args): void { |
||
2 ignored issues
–
show
|
|||
42 | // call to repository... |
||
43 | }, |
||
44 | ], |
||
45 | 'posts' => [ |
||
46 | 'type' => Type::listOf($this->types->getOutput(Post::class)), // Use automated ObjectType for output |
||
47 | 'resolve' => function ($root, $args): void { |
||
2 ignored issues
–
show
|
|||
48 | // call to repository... |
||
49 | }, |
||
50 | ], |
||
51 | ], |
||
52 | ]), |
||
53 | 'mutation' => new ObjectType([ |
||
54 | 'name' => 'mutation', |
||
55 | 'fields' => [ |
||
56 | 'createUser' => [ |
||
57 | 'type' => Type::nonNull($this->types->getOutput(User::class)), |
||
58 | 'args' => [ |
||
59 | 'input' => Type::nonNull($this->types->getInput(User::class)), // Use automated InputObjectType for input |
||
60 | ], |
||
61 | 'resolve' => function ($root, $args): void { |
||
2 ignored issues
–
show
|
|||
62 | // create new user and flush... |
||
63 | }, |
||
64 | ], |
||
65 | 'updateUser' => [ |
||
66 | 'type' => Type::nonNull($this->types->getOutput(User::class)), |
||
67 | 'args' => [ |
||
68 | 'id' => Type::nonNull(Type::id()), // Use standard API when needed |
||
69 | 'input' => $this->types->getInput(User::class), |
||
70 | ], |
||
71 | 'resolve' => function ($root, $args): void { |
||
2 ignored issues
–
show
|
|||
72 | // update existing user and flush... |
||
73 | }, |
||
74 | ], |
||
75 | 'createPost' => [ |
||
76 | 'type' => Type::nonNull($this->types->getOutput(Post::class)), |
||
77 | 'args' => [ |
||
78 | 'input' => Type::nonNull($this->types->getInput(Post::class)), // Use automated InputObjectType for input |
||
79 | ], |
||
80 | 'resolve' => function ($root, $args): void { |
||
2 ignored issues
–
show
|
|||
81 | // create new post and flush... |
||
82 | }, |
||
83 | ], |
||
84 | 'updatePost' => [ |
||
85 | 'type' => Type::nonNull($this->types->getOutput(Post::class)), |
||
86 | 'args' => [ |
||
87 | 'id' => Type::nonNull(Type::id()), // Use standard API when needed |
||
88 | 'input' => $this->types->getInput(Post::class), |
||
89 | ], |
||
90 | 'resolve' => function ($root, $args): void { |
||
2 ignored issues
–
show
|
|||
91 | // update existing post and flush... |
||
92 | }, |
||
93 | ], |
||
94 | ], |
||
95 | ]), |
||
96 | ]); |
||
97 | |||
98 | $schema->assertValid(); |
||
99 | self::assertTrue(true, 'passed validation successfully'); |
||
100 | } |
||
158 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.