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