Conditions | 13 |
Paths | 30 |
Total Lines | 34 |
Code Lines | 18 |
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 (($user = $this->flickr->get('flickr.people.findByUsername', ['username' => $this->profileId])) |
||
89 | && ($user instanceof Utils\ArrayHash) |
||
90 | && ($result = $this->flickr->get('flickr.people.getInfo', ['user_id' => $user->user->id])) |
||
91 | && ($result instanceof Utils\ArrayHash) |
||
92 | ) { |
||
93 | $this->details = $result->person; |
||
94 | } |
||
95 | |||
96 | } else if ($user = $this->flickr->getUser()) { |
||
97 | if (($result = $this->flickr->get('flickr.people.getInfo', ['user_id' => $user])) && ($result instanceof Utils\ArrayHash)) { |
||
98 | $this->details = $result->person; |
||
99 | } |
||
100 | |||
101 | } else { |
||
102 | $this->details = new Utils\ArrayHash; |
||
103 | } |
||
104 | |||
105 | } catch (\Exception $e) { |
||
106 | // todo: log? |
||
107 | } |
||
108 | } |
||
109 | |||
110 | if ($key !== NULL) { |
||
111 | return isset($this->details[$key]) ? $this->details[$key] : NULL; |
||
112 | } |
||
113 | |||
114 | return $this->details; |
||
115 | } |
||
116 | } |