Conditions | 1 |
Paths | 1 |
Total Lines | 59 |
Code Lines | 35 |
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 |
||
28 | public function setUp() |
||
29 | { |
||
30 | $this->interfaceType = new InterfaceType([ |
||
31 | 'name' => 'Interface', |
||
32 | 'fields' => ['fieldName' => ['type' => Type::string()]], |
||
33 | ]); |
||
34 | |||
35 | $this->implementingType = new ObjectType([ |
||
36 | 'name' => 'Object', |
||
37 | 'interfaces' => [$this->interfaceType], |
||
38 | 'fields' => ['fieldName' => ['type' => Type::string(), 'resolve' => function () { |
||
39 | return ''; |
||
40 | }]], |
||
41 | ]); |
||
42 | |||
43 | $this->directiveInputType = new InputObjectType([ |
||
44 | 'name' => 'DirInput', |
||
45 | 'fields' => [ |
||
46 | 'field' => [ |
||
47 | 'type' => Type::string(), |
||
48 | ], |
||
49 | ], |
||
50 | ]); |
||
51 | |||
52 | $this->wrappedDirectiveInputType = new InputObjectType([ |
||
53 | 'name' => 'WrappedDirInput', |
||
54 | 'fields' => [ |
||
55 | 'field' => [ |
||
56 | 'type' => Type::string(), |
||
57 | ], |
||
58 | ], |
||
59 | ]); |
||
60 | |||
61 | $this->directive = new Directive([ |
||
62 | 'name' => 'dir', |
||
63 | 'locations' => ['OBJECT'], |
||
64 | 'args' => [ |
||
65 | 'arg' => [ |
||
66 | 'type' => $this->directiveInputType, |
||
67 | ], |
||
68 | 'argList' => [ |
||
69 | 'type' => Type::listOf($this->wrappedDirectiveInputType), |
||
70 | ], |
||
71 | ], |
||
72 | ]); |
||
73 | |||
74 | $this->schema = new Schema([ |
||
75 | 'query' => new ObjectType([ |
||
76 | 'name' => 'Query', |
||
77 | 'fields' => [ |
||
78 | 'getObject' => [ |
||
79 | 'type' => $this->interfaceType, |
||
80 | 'resolve' => function () { |
||
81 | return []; |
||
82 | }, |
||
83 | ], |
||
84 | ], |
||
85 | ]), |
||
86 | 'directives' => [$this->directive], |
||
87 | ]); |
||
121 |