| Conditions | 13 |
| Paths | 8 |
| Total Lines | 31 |
| Code Lines | 19 |
| 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 |
||
| 33 | public function isCompatible(AssociationStubBase $otherStub) |
||
| 34 | { |
||
| 35 | if (!parent::isCompatible($otherStub)) { |
||
| 36 | return false; |
||
| 37 | } |
||
| 38 | $thisTarg = $this->getTargType(); |
||
| 39 | $thatTarg = $otherStub->getTargType(); |
||
| 40 | $thisNull = null === $thisTarg; |
||
| 41 | $thatNull = null === $thatTarg; |
||
| 42 | if ($thisNull == $thatNull) { |
||
| 43 | return false; |
||
| 44 | } |
||
| 45 | if ($thisNull && ($thatTarg != $this->getBaseType())) { |
||
| 46 | return false; |
||
| 47 | } |
||
| 48 | if ($thatNull && ($thisTarg != $otherStub->getBaseType())) { |
||
| 49 | return false; |
||
| 50 | } |
||
| 51 | |||
| 52 | if (AssociationStubRelationType::MANY() == $this->getMultiplicity() |
||
| 53 | && AssociationStubRelationType::MANY() == $otherStub->getMultiplicity()) { |
||
| 54 | if ($thisNull && ($otherStub->getForeignField() != $this->getKeyField())) { |
||
| 55 | return false; |
||
| 56 | } |
||
| 57 | |||
| 58 | if ($thatNull && ($this->getForeignField() != $otherStub->getKeyField())) { |
||
| 59 | return false; |
||
| 60 | } |
||
| 61 | } |
||
| 62 | |||
| 63 | return true; |
||
| 64 | } |
||
| 72 |