| 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 conflicts(MappingInterface $subject, MappingInterface $opponent): bool |
||
| 26 | { |
||
| 27 | if ($subject->getType() && $opponent->getType() && $subject->getType() !== $opponent->getType()) { |
||
| 28 | return true; |
||
| 29 | } |
||
| 30 | foreach ($subject->getParameters() as $parameter => $value) { |
||
| 31 | if ($opponent->hasParameter($parameter) && $opponent->getParameter($parameter) != $value) { |
||
| 32 | return true; |
||
| 33 | } |
||
| 34 | } |
||
| 35 | foreach ($subject->getProperties() as $name => $property) { |
||
| 36 | if ($opponent->hasProperty($name) && static::conflicts($property, $opponent->getProperty($name))) { |
||
| 37 | return true; |
||
| 38 | } |
||
| 39 | } |
||
| 40 | return false; |
||
| 41 | } |
||
| 43 |
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: