| Conditions | 10 |
| Paths | 512 |
| Total Lines | 32 |
| Code Lines | 20 |
| 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 |
||
| 73 | public function normalize($object, $format = null, array $context = []) |
||
| 74 | { |
||
| 75 | $data = new \stdClass(); |
||
| 76 | if (null !== $object->getActions()) { |
||
| 77 | $data->{'Actions'} = $object->getActions(); |
||
| 78 | } |
||
| 79 | if (null !== $object->getExternalReferences()) { |
||
| 80 | $data->{'ExternalReferences'} = $object->getExternalReferences(); |
||
| 81 | } |
||
| 82 | if (null !== $object->getImpact()) { |
||
| 83 | $data->{'Impact'} = $object->getImpact(); |
||
| 84 | } |
||
| 85 | if (null !== $object->getProofOfConcept()) { |
||
| 86 | $data->{'ProofOfConcept'} = $object->getProofOfConcept(); |
||
| 87 | } |
||
| 88 | if (null !== $object->getRemedy()) { |
||
| 89 | $data->{'Remedy'} = $object->getRemedy(); |
||
| 90 | } |
||
| 91 | if (null !== $object->getRemedyReferences()) { |
||
| 92 | $data->{'RemedyReferences'} = $object->getRemedyReferences(); |
||
| 93 | } |
||
| 94 | if (null !== $object->getSkills()) { |
||
| 95 | $data->{'Skills'} = $object->getSkills(); |
||
| 96 | } |
||
| 97 | if (null !== $object->getSummary()) { |
||
| 98 | $data->{'Summary'} = $object->getSummary(); |
||
| 99 | } |
||
| 100 | if (null !== $object->getType()) { |
||
| 101 | $data->{'Type'} = $object->getType(); |
||
| 102 | } |
||
| 103 | |||
| 104 | return $data; |
||
| 105 | } |
||
| 107 |