| Conditions | 10 |
| Paths | 8 |
| Total Lines | 16 |
| Code Lines | 9 |
| 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 |
||
| 25 | private static function haveConflicts(MappingInterface $subject, MappingInterface $opponent): bool |
||
| 26 | { |
||
| 27 | if (static::haveTypeConflict($subject, $opponent)) { |
||
| 28 | return true; |
||
| 29 | } |
||
| 30 | if (static::haveParameterConflicts($subject, $opponent)) { |
||
| 31 | return true; |
||
| 32 | } |
||
| 33 | return static::havePropertyConflicts($subject, $opponent); |
||
| 34 | } |
||
| 35 | |||
| 36 | private static function haveTypeConflict(MappingInterface $subject, MappingInterface $opponent): bool |
||
| 37 | { |
||
| 38 | return $subject->getType() && $opponent->getType() && $subject->getType() !== $opponent->getType(); |
||
| 39 | } |
||
| 40 | |||
| 41 | private static function haveParameterConflicts(MappingInterface $subject, MappingInterface $opponent): bool |
||
| 61 |
If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration: