Conditions | 11 |
Paths | 30 |
Total Lines | 30 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
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 |
||
82 | public function getDetails($key = NULL) |
||
83 | { |
||
84 | if ($this->details === NULL) { |
||
85 | try { |
||
86 | |||
87 | if ($this->profileId !== NULL) { |
||
88 | if (($result = $this->fiveHundredPixel->get('users/show', ['username' => $this->profileId])) && ($result instanceof Utils\ArrayHash)) { |
||
89 | $this->details = $result->user; |
||
90 | } |
||
91 | |||
92 | } else if ($this->fiveHundredPixel->getUser()) { |
||
93 | if (($result = $this->fiveHundredPixel->get('users')) && ($result instanceof Utils\ArrayHash)) { |
||
94 | $this->details = $result->user; |
||
95 | } |
||
96 | |||
97 | } else { |
||
98 | $this->details = new Utils\ArrayHash; |
||
99 | } |
||
100 | |||
101 | } catch (\Exception $e) { |
||
102 | // todo: log? |
||
103 | } |
||
104 | } |
||
105 | |||
106 | if ($key !== NULL) { |
||
107 | return isset($this->details[$key]) ? $this->details[$key] : NULL; |
||
108 | } |
||
109 | |||
110 | return $this->details; |
||
111 | } |
||
112 | } |