Conditions | 7 |
Paths | 3 |
Total Lines | 51 |
Code Lines | 25 |
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 |
||
91 | public function getFullInfo($api_key, $api_secret, $domain) |
||
92 | { |
||
93 | $expiration_date = ''; |
||
94 | $dns_servers = array(); |
||
95 | $privacy_status = ''; |
||
96 | $autorenewal_status = ''; |
||
97 | |||
98 | $api_url = $this->getApiUrl($domain, 'info'); |
||
99 | $api_results = $this->apiCall($api_key, $api_secret, $api_url); |
||
100 | $array_results = $this->convertToArray($api_results); |
||
101 | |||
102 | // confirm that the api call was successful |
||
103 | /* |
||
104 | * The $array_results['expires'] and $array_results['contactRegistrant']['nameFirst'] checks were put in place |
||
105 | * because GoDaddy's domain list API command returns domains that aren't necessarily registered with them (such |
||
106 | * as domains that are registered elsewhere but the DNS is hosted at GoDaddy). These additional checks ensure |
||
107 | * that the domain details will only be processed for domains that are actually registered at GoDaddy. |
||
108 | */ |
||
109 | if (isset($array_results['domain']) && isset($array_results['expires']) && isset($array_results['contactRegistrant']['nameFirst'])) { |
||
110 | |||
111 | // get expiration date |
||
112 | $expiration_date = substr($array_results['expires'], 0, 10); |
||
113 | |||
114 | // get dns servers |
||
115 | $dns_result = $array_results['nameServers']; |
||
116 | $dns_servers = $this->processDns($dns_result); |
||
117 | |||
118 | // get privacy status |
||
119 | $privacy_result = (string) $array_results['privacy']; |
||
120 | $privacy_status = $this->processPrivacy($privacy_result); |
||
121 | |||
122 | // get auto renewal status |
||
123 | $autorenewal_result = (string) $array_results['renewAuto']; |
||
124 | $autorenewal_status = $this->processAutorenew($autorenewal_result); |
||
125 | |||
126 | } elseif (isset($array_results['domain']) && !isset($array_results['expires']) && !isset($array_results['contactRegistrant']['nameFirst'])) { |
||
127 | |||
128 | $domain_status = 'invalid'; |
||
129 | $log_message = 'Invalid domain (not registered at GoDaddy)'; |
||
130 | $log_extra = array('Domain' => $domain, 'API Key' => $this->format->obfusc($api_key), 'API Secret' => $this->format->obfusc($api_secret)); |
||
131 | $this->log->warning($log_message, $log_extra); |
||
132 | |||
133 | } else { |
||
134 | |||
135 | $log_message = 'Unable to get domain details'; |
||
136 | $log_extra = array('Domain' => $domain, 'API Key' => $this->format->obfusc($api_key), 'API Secret' => $this->format->obfusc($api_secret)); |
||
137 | $this->log->error($log_message, $log_extra); |
||
138 | |||
139 | } |
||
140 | |||
141 | return array($domain_status, $expiration_date, $dns_servers, $privacy_status, $autorenewal_status); |
||
|
|||
142 | } |
||
182 |