| Conditions | 10 |
| Paths | 96 |
| Total Lines | 26 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 80 | public function denormalize($data, $class, $format = null, array $context = array()) |
||
| 81 | { |
||
| 82 | $mbox = isset($data['mbox']) ? $data['mbox'] : null; |
||
| 83 | $mboxSha1Sum = isset($data['mboxSha1Sum']) ? $data['mboxSha1Sum'] : null; |
||
| 84 | $openId = isset($data['openid']) ? $data['openid'] : null; |
||
| 85 | $name = isset($data['name']) ? $data['name'] : null; |
||
| 86 | $account = null; |
||
| 87 | |||
| 88 | if (isset($data['account'])) { |
||
| 89 | $account = $this->denormalizeData($data['account'], 'Xabbuh\XApi\Model\Account'); |
||
| 90 | } |
||
| 91 | |||
| 92 | if (isset($data['objectType']) && 'Group' === $data['objectType']) { |
||
| 93 | $members = array(); |
||
| 94 | |||
| 95 | if (isset($data['member'])) { |
||
| 96 | foreach ($data['member'] as $member) { |
||
| 97 | $members[] = $this->denormalize($member, 'Xabbuh\XApi\Model\Agent'); |
||
| 98 | } |
||
| 99 | } |
||
| 100 | |||
| 101 | return new Group($mbox, $mboxSha1Sum, $openId, $account, $name, $members); |
||
| 102 | } |
||
| 103 | |||
| 104 | return new Agent($mbox, $mboxSha1Sum, $openId, $account, $name); |
||
| 105 | } |
||
| 106 | |||
| 115 |