Conditions | 14 |
Paths | 272 |
Total Lines | 56 |
Code Lines | 30 |
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 |
||
164 | public function getModel() |
||
165 | { |
||
166 | $context = new ContextModel(); |
||
167 | $context = $context->withRegistration($this->registration); |
||
168 | $context = $context->withRevision($this->revision); |
||
169 | $context = $context->withPlatform($this->platform); |
||
170 | $context = $context->withLanguage($this->language); |
||
171 | |||
172 | if (null !== $this->instructor) { |
||
173 | $context = $context->withInstructor($this->instructor->getModel()); |
||
174 | } |
||
175 | |||
176 | if (null !== $this->team) { |
||
177 | $context = $context->withTeam($this->team->getModel()); |
||
178 | } |
||
179 | |||
180 | if ($this->hasContextActivities) { |
||
181 | $contextActivities = new ContextActivities(); |
||
182 | |||
183 | if (null !== $this->parentActivities) { |
||
184 | foreach ($this->parentActivities as $contextParentActivity) { |
||
185 | $contextActivities = $contextActivities->withAddedParentActivity($contextParentActivity->getModel()); |
||
186 | } |
||
187 | } |
||
188 | |||
189 | if (null !== $this->groupingActivities) { |
||
190 | foreach ($this->groupingActivities as $contextGroupingActivity) { |
||
191 | $contextActivities = $contextActivities->withAddedGroupingActivity($contextGroupingActivity->getModel()); |
||
192 | } |
||
193 | } |
||
194 | |||
195 | if (null !== $this->categoryActivities) { |
||
196 | foreach ($this->categoryActivities as $contextCategoryActivity) { |
||
197 | $contextActivities = $contextActivities->withAddedCategoryActivity($contextCategoryActivity->getModel()); |
||
198 | } |
||
199 | } |
||
200 | |||
201 | if (null !== $this->otherActivities) { |
||
202 | foreach ($this->otherActivities as $contextOtherActivity) { |
||
203 | $contextActivities = $contextActivities->withAddedOtherActivity($contextOtherActivity->getModel()); |
||
204 | } |
||
205 | } |
||
206 | |||
207 | $context = $context->withContextActivities($contextActivities); |
||
208 | } |
||
209 | |||
210 | if (null !== $this->statement) { |
||
211 | $context = $context->withStatement(new StatementReference(StatementId::fromString($this->statement))); |
||
212 | } |
||
213 | |||
214 | if (null !== $this->extensions) { |
||
215 | $context = $context->withExtensions($this->extensions->getModel()); |
||
216 | } |
||
217 | |||
218 | return $context; |
||
219 | } |
||
220 | } |
||
221 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..