| Conditions | 11 |
| Paths | 30 |
| Total Lines | 30 |
| 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 |
||
| 82 | public function getDetails($key = NULL) |
||
| 83 | { |
||
| 84 | if ($this->details === NULL) { |
||
| 85 | try { |
||
| 86 | |||
| 87 | if ($this->profileId !== NULL) { |
||
| 88 | if (($result = $this->twitter->get('users/show.json', ['screen_name' => $this->profileId])) && ($result instanceof Utils\ArrayHash)) { |
||
| 89 | $this->details = $result; |
||
| 90 | } |
||
| 91 | |||
| 92 | } else if ($user = $this->twitter->getUser()) { |
||
| 93 | if (($result = $this->twitter->get('users/show.json', ['user_id' => $user])) && ($result instanceof Utils\ArrayHash)) { |
||
| 94 | $this->details = $result; |
||
| 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 | } |