Conditions | 1 |
Paths | 1 |
Total Lines | 74 |
Code Lines | 25 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 1 | Features | 1 |
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 |
||
34 | public function dataProvider() |
||
35 | { |
||
36 | return [ |
||
37 | [ |
||
38 | '{ |
||
39 | list : unionList { |
||
40 | name, |
||
41 | ... on FirstType { |
||
42 | secondName |
||
43 | } |
||
44 | } |
||
45 | }', |
||
46 | [ |
||
47 | 'data' => [ |
||
48 | 'list' => [ |
||
49 | ['name' => 'object 1'], |
||
50 | ['name' => 'object 2', 'secondName' => 'object second name 2'], |
||
51 | ['name' => 'object 3'], |
||
52 | ['name' => 'object 4', 'secondName' => 'object second name 4'] |
||
53 | ] |
||
54 | ] |
||
55 | ] |
||
56 | ], |
||
57 | [ |
||
58 | '{ |
||
59 | oneUnion { |
||
60 | name, |
||
61 | ... on FirstType { |
||
62 | secondName |
||
63 | } |
||
64 | } |
||
65 | }', |
||
66 | [ |
||
67 | 'data' => [ |
||
68 | 'oneUnion' => [ |
||
69 | 'name' => 'object one', |
||
70 | 'secondName' => 'second name' |
||
71 | ] |
||
72 | ] |
||
73 | ] |
||
74 | ], |
||
75 | [ |
||
76 | '{ |
||
77 | list : unionList { |
||
78 | name |
||
79 | } |
||
80 | }', |
||
81 | [ |
||
82 | 'data' => [ |
||
83 | 'list' => [ |
||
84 | ['name' => 'object 1'], |
||
85 | ['name' => 'object 2'], |
||
86 | ['name' => 'object 3'], |
||
87 | ['name' => 'object 4'] |
||
88 | ] |
||
89 | ] |
||
90 | ] |
||
91 | ], |
||
92 | [ |
||
93 | '{ |
||
94 | oneUnion { |
||
95 | name |
||
96 | } |
||
97 | }', |
||
98 | [ |
||
99 | 'data' => [ |
||
100 | 'oneUnion' => [ |
||
101 | 'name' => 'object one' |
||
102 | ] |
||
103 | ] |
||
104 | ] |
||
105 | ], |
||
106 | ]; |
||
107 | } |
||
108 | |||
109 | } |