Conditions | 1 |
Paths | 1 |
Total Lines | 154 |
Code Lines | 108 |
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 |
||
94 | public function getFiltersMultiple() |
||
95 | { |
||
96 | return array( |
||
97 | array(array( |
||
98 | 'choiceType' => ChoiceType::TYPE_NOT_CONTAINS, |
||
99 | 'value' => 'somevalue', |
||
100 | 'qbNodeCount' => 6, |
||
101 | 'assertPaths' => array( |
||
102 | 'where.constraint.constraint[0].constraint.operand_dynamic' => array( |
||
103 | 'getAlias' => 'a', |
||
104 | 'getField' => 'somefield', |
||
105 | ), |
||
106 | 'where.constraint.constraint[0].constraint.operand_static' => array( |
||
107 | 'getValue' => '%somevalue%', |
||
108 | ), |
||
109 | ), |
||
110 | )), |
||
111 | array(array( |
||
112 | 'choiceType' => ChoiceType::TYPE_NOT_CONTAINS, |
||
113 | 'value' => array('somevalue', 'somevalue'), |
||
114 | 'qbNodeCount' => 10, |
||
115 | 'assertPaths' => array( |
||
116 | 'where.constraint.constraint.constraint.operand_dynamic' => array( |
||
117 | 'getAlias' => 'a', |
||
118 | 'getField' => 'somefield', |
||
119 | ), |
||
120 | 'where.constraint.constraint.constraint.operand_static' => array( |
||
121 | 'getValue' => '%somevalue%', |
||
122 | ), |
||
123 | 'where.constraint.constraint[1].constraint.operand_dynamic' => array( |
||
124 | 'getAlias' => 'a', |
||
125 | 'getField' => 'somefield', |
||
126 | ), |
||
127 | 'where.constraint.constraint[1].constraint.operand_static' => array( |
||
128 | 'getValue' => '%somevalue%', |
||
129 | ), |
||
130 | ), |
||
131 | )), |
||
132 | array(array( |
||
133 | 'choiceType' => ChoiceType::TYPE_CONTAINS, |
||
134 | 'value' => 'somevalue', |
||
135 | 'qbNodeCount' => 5, |
||
136 | 'assertPaths' => array( |
||
137 | 'where.constraint.constraint.operand_dynamic' => array( |
||
138 | 'getAlias' => 'a', |
||
139 | 'getField' => 'somefield', |
||
140 | ), |
||
141 | 'where.constraint.constraint.operand_static' => array( |
||
142 | 'getValue' => '%somevalue%', |
||
143 | ), |
||
144 | 'where.constraint.constraint.operand_static' => array( |
||
145 | 'getValue' => '%somevalue%', |
||
146 | ), |
||
147 | ), |
||
148 | )), |
||
149 | array(array( |
||
150 | 'choiceType' => ChoiceType::TYPE_CONTAINS, |
||
151 | 'value' => array('somevalue', 'somevalue'), |
||
152 | 'qbNodeCount' => 8, |
||
153 | 'assertPaths' => array( |
||
154 | 'where.constraint.constraint.operand_dynamic' => array( |
||
155 | 'getAlias' => 'a', |
||
156 | 'getField' => 'somefield', |
||
157 | ), |
||
158 | 'where.constraint.constraint.operand_static' => array( |
||
159 | 'getValue' => '%somevalue%', |
||
160 | ), |
||
161 | 'where.constraint.constraint[1].operand_dynamic' => array( |
||
162 | 'getAlias' => 'a', |
||
163 | 'getField' => 'somefield', |
||
164 | ), |
||
165 | 'where.constraint.constraint[1].operand_static' => array( |
||
166 | 'getValue' => '%somevalue%', |
||
167 | ), |
||
168 | ), |
||
169 | )), |
||
170 | array(array( |
||
171 | 'choiceType' => ChoiceType::TYPE_CONTAINS, |
||
172 | 'value' => 'somevalue', |
||
173 | 'qbNodeCount' => 5, |
||
174 | 'assertPaths' => array( |
||
175 | 'where.constraint.constraint.operand_dynamic' => array( |
||
176 | 'getAlias' => 'a', |
||
177 | 'getField' => 'somefield', |
||
178 | ), |
||
179 | 'where.constraint.constraint.operand_static' => array( |
||
180 | 'getValue' => '%somevalue%', |
||
181 | ), |
||
182 | 'where.constraint.constraint.operand_static' => array( |
||
183 | 'getValue' => '%somevalue%', |
||
184 | ), |
||
185 | ), |
||
186 | )), |
||
187 | array(array( |
||
188 | 'choiceType' => ChoiceType::TYPE_CONTAINS, |
||
189 | 'value' => array('somevalue', 'somevalue'), |
||
190 | 'qbNodeCount' => 8, |
||
191 | 'assertPaths' => array( |
||
192 | 'where.constraint.constraint.operand_dynamic' => array( |
||
193 | 'getAlias' => 'a', |
||
194 | 'getField' => 'somefield', |
||
195 | ), |
||
196 | 'where.constraint.constraint.operand_static' => array( |
||
197 | 'getValue' => '%somevalue%', |
||
198 | ), |
||
199 | 'where.constraint.constraint[1].operand_dynamic' => array( |
||
200 | 'getAlias' => 'a', |
||
201 | 'getField' => 'somefield', |
||
202 | ), |
||
203 | 'where.constraint.constraint[1].operand_static' => array( |
||
204 | 'getValue' => '%somevalue%', |
||
205 | ), |
||
206 | ), |
||
207 | )), |
||
208 | array(array( |
||
209 | 'choiceType' => ChoiceType::TYPE_EQUAL, |
||
210 | 'value' => 'somevalue', |
||
211 | 'qbNodeCount' => 5, |
||
212 | 'assertPaths' => array( |
||
213 | 'where.constraint.constraint.operand_dynamic' => array( |
||
214 | 'getAlias' => 'a', |
||
215 | 'getField' => 'somefield', |
||
216 | ), |
||
217 | 'where.constraint.constraint.operand_static' => array( |
||
218 | 'getValue' => 'somevalue', |
||
219 | ), |
||
220 | 'where.constraint.constraint.operand_static' => array( |
||
221 | 'getValue' => 'somevalue', |
||
222 | ), |
||
223 | ), |
||
224 | )), |
||
225 | array(array( |
||
226 | 'choiceType' => ChoiceType::TYPE_EQUAL, |
||
227 | 'value' => array('somevalue', 'somevalue'), |
||
228 | 'qbNodeCount' => 8, |
||
229 | 'assertPaths' => array( |
||
230 | 'where.constraint.constraint.operand_dynamic' => array( |
||
231 | 'getAlias' => 'a', |
||
232 | 'getField' => 'somefield', |
||
233 | ), |
||
234 | 'where.constraint.constraint.operand_static' => array( |
||
235 | 'getValue' => 'somevalue', |
||
236 | ), |
||
237 | 'where.constraint.constraint[1].operand_dynamic' => array( |
||
238 | 'getAlias' => 'a', |
||
239 | 'getField' => 'somefield', |
||
240 | ), |
||
241 | 'where.constraint.constraint[1].operand_static' => array( |
||
242 | 'getValue' => 'somevalue', |
||
243 | ), |
||
244 | ), |
||
245 | )), |
||
246 | ); |
||
247 | } |
||
248 | |||
284 |
If you implement
__call
and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__call
is implemented by a parent class and only the child class knows which methods exist: