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