| Conditions | 11 |
| Paths | 39 |
| Total Lines | 15 |
| Code Lines | 7 |
| 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 |
||
| 132 | public function equals(Property $property): bool |
||
| 133 | { |
||
| 134 | // If the properties are new-build, they are the same ones if the name of their apartment building are equal |
||
| 135 | if ($this->newBuild && null !== $this->buildingName && $property->isNewBuild()) { |
||
| 136 | return $this->buildingName === $property->getBuildingName(); |
||
| 137 | } |
||
| 138 | |||
| 139 | $sameArea = null !== $this->area && abs($this->area - $property->getArea()) <= 1; |
||
| 140 | |||
| 141 | // Properties are equal if their price are equal, as long as the price doesn't finish with a so common "000" |
||
| 142 | // or if their area are pretty much equal |
||
| 143 | return |
||
| 144 | (null !== $this->price && $this->price === $property->getPrice()) && |
||
| 145 | ((null !== $this->area && null !== $property->getArea()) ? $sameArea : true) && |
||
| 146 | ('000' !== substr($this->price, -3) || $sameArea); |
||
| 147 | } |
||
| 149 |