Conditions | 14 |
Paths | 10 |
Total Lines | 40 |
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 |
||
97 | public function equals(Attachment $attachment): bool |
||
98 | { |
||
99 | if (!$this->usageType->equals($attachment->usageType)) { |
||
100 | return false; |
||
101 | } |
||
102 | |||
103 | if ($this->contentType !== $attachment->contentType) { |
||
104 | return false; |
||
105 | } |
||
106 | |||
107 | if ($this->length !== $attachment->length) { |
||
108 | return false; |
||
109 | } |
||
110 | |||
111 | if ($this->sha2 !== $attachment->sha2) { |
||
112 | return false; |
||
113 | } |
||
114 | |||
115 | if (!$this->display->equals($attachment->display)) { |
||
116 | return false; |
||
117 | } |
||
118 | |||
119 | if (null !== $this->description xor null !== $attachment->description) { |
||
120 | return false; |
||
121 | } |
||
122 | |||
123 | if (null !== $this->description && null !== $attachment->description && !$this->description->equals($attachment->description)) { |
||
124 | return false; |
||
125 | } |
||
126 | |||
127 | if (null !== $this->fileUrl xor null !== $attachment->fileUrl) { |
||
128 | return false; |
||
129 | } |
||
130 | |||
131 | if (null !== $this->fileUrl && null !== $attachment->fileUrl && !$this->fileUrl->equals($attachment->fileUrl)) { |
||
132 | return false; |
||
133 | } |
||
134 | |||
135 | return true; |
||
136 | } |
||
137 | } |
||
138 |