| Conditions | 15 |
| Paths | 17 |
| Total Lines | 52 |
| Code Lines | 26 |
| 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 |
||
| 81 | public function equals(Definition $definition) |
||
| 82 | { |
||
| 83 | if (!parent::equals($definition)) { |
||
| 84 | return false; |
||
| 85 | } |
||
| 86 | |||
| 87 | if (!$definition instanceof MatchingInteractionDefinition) { |
||
| 88 | return false; |
||
| 89 | } |
||
| 90 | |||
| 91 | if (null !== $this->source xor null !== $definition->source) { |
||
| 92 | return false; |
||
| 93 | } |
||
| 94 | |||
| 95 | if (null !== $this->target xor null !== $definition->target) { |
||
| 96 | return false; |
||
| 97 | } |
||
| 98 | |||
| 99 | if (null !== $this->source) { |
||
| 100 | if (count($this->source) !== count($definition->source)) { |
||
| 101 | return false; |
||
| 102 | } |
||
| 103 | |||
| 104 | foreach ($this->source as $key => $source) { |
||
| 105 | if (!isset($definition->source[$key])) { |
||
| 106 | return false; |
||
| 107 | } |
||
| 108 | |||
| 109 | if (!$source->equals($definition->source[$key])) { |
||
| 110 | return false; |
||
| 111 | } |
||
| 112 | } |
||
| 113 | } |
||
| 114 | |||
| 115 | if (null !== $this->target) { |
||
| 116 | if (count($this->target) !== count($definition->target)) { |
||
| 117 | return false; |
||
| 118 | } |
||
| 119 | |||
| 120 | foreach ($this->target as $key => $target) { |
||
| 121 | if (!isset($definition->target[$key])) { |
||
| 122 | return false; |
||
| 123 | } |
||
| 124 | |||
| 125 | if (!$target->equals($definition->target[$key])) { |
||
| 126 | return false; |
||
| 127 | } |
||
| 128 | } |
||
| 129 | } |
||
| 130 | |||
| 131 | return true; |
||
| 132 | } |
||
| 133 | } |
||
| 134 |