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