Conditions | 1 |
Paths | 1 |
Total Lines | 52 |
Code Lines | 24 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | 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 |
||
113 | public function finalClassProvider() : array |
||
114 | { |
||
115 | $astLocator = (new BetterReflection())->astLocator(); |
||
116 | |||
117 | return [ |
||
118 | 'final class' => [ |
||
119 | new StringSourceLocator( |
||
120 | <<<'PHP' |
||
121 | <?php |
||
122 | |||
123 | final class TheClass { |
||
124 | protected $b; |
||
125 | } |
||
126 | PHP |
||
127 | , |
||
128 | $astLocator |
||
129 | ), |
||
130 | new StringSourceLocator( |
||
131 | <<<'PHP' |
||
132 | <?php |
||
133 | final class TheClass { |
||
134 | private $b; |
||
135 | } |
||
136 | PHP |
||
137 | , |
||
138 | $astLocator |
||
139 | ), |
||
140 | ], |
||
141 | 'final class extending baseclass' => [ |
||
142 | new StringSourceLocator( |
||
143 | <<<'PHP' |
||
144 | <?php |
||
145 | abstract class baseClass {} |
||
146 | |||
147 | final class TheClass extends baseClass { |
||
148 | protected $b; |
||
149 | } |
||
150 | PHP |
||
151 | , |
||
152 | $astLocator |
||
153 | ), |
||
154 | new StringSourceLocator( |
||
155 | <<<'PHP' |
||
156 | <?php |
||
157 | abstract class baseClass {} |
||
158 | |||
159 | final class TheClass extends baseClass{ |
||
160 | private $b; |
||
161 | } |
||
162 | PHP |
||
163 | , |
||
164 | $astLocator |
||
165 | ), |
||
171 |