Conditions | 18 |
Paths | 14 |
Total Lines | 56 |
Code Lines | 28 |
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 |
||
195 | public function equals(Context $context) |
||
196 | { |
||
197 | if ($this->registration !== $context->registration) { |
||
198 | return false; |
||
199 | } |
||
200 | |||
201 | if (null !== $this->instructor xor null !== $context->instructor) { |
||
202 | return false; |
||
203 | } |
||
204 | |||
205 | if (null !== $this->instructor && !$this->instructor->equals($context->instructor)) { |
||
206 | return false; |
||
207 | } |
||
208 | |||
209 | if (null !== $this->team xor null !== $context->team) { |
||
210 | return false; |
||
211 | } |
||
212 | |||
213 | if (null !== $this->team && !$this->team->equals($context->instructor)) { |
||
214 | return false; |
||
215 | } |
||
216 | |||
217 | if ($this->contextActivities != $context->contextActivities) { |
||
218 | return false; |
||
219 | } |
||
220 | |||
221 | if ($this->revision !== $context->revision) { |
||
222 | return false; |
||
223 | } |
||
224 | |||
225 | if ($this->platform !== $context->platform) { |
||
226 | return false; |
||
227 | } |
||
228 | |||
229 | if ($this->language !== $context->language) { |
||
230 | return false; |
||
231 | } |
||
232 | |||
233 | if (null !== $this->statement xor null !== $context->statement) { |
||
234 | return false; |
||
235 | } |
||
236 | |||
237 | if (null !== $this->statement && !$this->statement->equals($context->instructor)) { |
||
238 | return false; |
||
239 | } |
||
240 | |||
241 | if (null !== $this->extensions xor null !== $context->extensions) { |
||
242 | return false; |
||
243 | } |
||
244 | |||
245 | if (null !== $this->extensions && !$this->extensions->equals($context->instructor)) { |
||
|
|||
246 | return false; |
||
247 | } |
||
248 | |||
249 | return true; |
||
250 | } |
||
251 | } |
||
252 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: