Conditions | 13 |
Paths | 33 |
Total Lines | 29 |
Code Lines | 19 |
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 |
||
93 | public function getAnyPhoneNumber() |
||
94 | { |
||
95 | $phoneNo = null; |
||
96 | $numbersRaw = $this->getFlexiData($this->getApiURL(), |
||
97 | ['detail' => 'custom:id,mobil,tel,kontakty(primarni,mobil,tel)', 'relations' => 'kontakty']); |
||
98 | if (is_array($numbersRaw) && !empty($numbersRaw[0])) { |
||
99 | $numbers = $numbersRaw[0]; |
||
100 | if (array_key_exists('mobil', $numbers) && strlen(trim($numbers['mobil']))) { |
||
101 | $phoneNo = $numbers['mobil']; |
||
102 | } |
||
103 | if (array_key_exists('tel', $numbers) && strlen(trim($numbers['tel']))) { |
||
104 | $phoneNo = $numbers['tel']; |
||
105 | } |
||
106 | if (array_key_exists('kontakty', $numbers) && !empty($numbers['kontakty'])) { |
||
107 | foreach ($numbers['kontakty'] as $kontakt) { |
||
108 | if ($kontakt['primarni'] == 'true') { |
||
109 | |||
110 | } |
||
111 | if (strlen(trim($kontakt['mobil']))) { |
||
112 | $phoneNo = $kontakt['mobil']; |
||
113 | break; |
||
114 | } elseif (strlen(trim($kontakt['mobil']))) { |
||
115 | $phoneNo = $kontakt['mobil']; |
||
116 | break; |
||
117 | } |
||
118 | } |
||
119 | } |
||
120 | } |
||
121 | return $phoneNo; |
||
122 | } |
||
142 |