| Conditions | 3 |
| Paths | 2 |
| Total Lines | 61 |
| Code Lines | 12 |
| 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 |
||
| 81 | public function getDeals(int $merchantID = 0) : array |
||
| 82 | { |
||
| 83 | $url = 'http://publisher.publicideas.com/xmlProgAff.php?partid='.$this->_partner_id.'&key='.$this->_token.'&noDownload=yes'; |
||
| 84 | $xml = file_get_contents($url); |
||
| 85 | $arrResult = array(); |
||
| 86 | $arrResponse = xml2array($xml); |
||
| 87 | if(!is_array($arrResponse) || count($arrResponse) <= 0) { |
||
| 88 | return $arrResult; |
||
| 89 | } |
||
| 90 | $arrPartner = $arrResponse['partner']; |
||
| 91 | echo '<pre>'; |
||
| 92 | var_dump($arrPartner); |
||
| 93 | echo '</pre>'; |
||
| 94 | |||
| 95 | /* |
||
| 96 | foreach($arrPartner as $partner) { |
||
| 97 | $Deal = Deal::createInstance(); |
||
| 98 | $Deal->program_name; |
||
| 99 | if($merchantID > 0) { |
||
| 100 | if($merchantID == $admediumItems['program']['@id']) { |
||
| 101 | $arrResult[] = $Deal; |
||
| 102 | } |
||
| 103 | } |
||
| 104 | else { |
||
| 105 | $arrResult[] = $Deal; |
||
| 106 | } |
||
| 107 | } |
||
| 108 | */ |
||
| 109 | |||
| 110 | |||
| 111 | |||
| 112 | /* |
||
| 113 | $this->_apiClient->setConnectId($this->_username); |
||
| 114 | $this->_apiClient->setSecretKey($this->_password); |
||
| 115 | $arrResponse = json_decode($this->_apiClient->getAdmedia(), true); |
||
| 116 | $arrAdmediumItems = $arrResponse['admediumItems']['admediumItem']; |
||
| 117 | $arrResult = array(); |
||
| 118 | foreach($arrAdmediumItems as $admediumItems) { |
||
| 119 | $Deal = Deal::createInstance(); |
||
| 120 | $Deal->deal_ID = (int)$admediumItems['@id']; |
||
| 121 | $Deal->name = $admediumItems['name']; |
||
| 122 | $Deal->deal_type = $admediumItems['admediumType']; |
||
| 123 | $Deal->merchant_ID = (int)$admediumItems['program']['@id']; |
||
| 124 | $Deal->ppv = $admediumItems['trackingLinks']['trackingLink'][0]['ppv']; |
||
| 125 | $Deal->ppc = $admediumItems['trackingLinks']['trackingLink'][0]['ppc']; |
||
| 126 | if($merchantID > 0) { |
||
| 127 | if($merchantID == $admediumItems['program']['@id']) { |
||
| 128 | $arrResult[] = $Deal; |
||
| 129 | } |
||
| 130 | } |
||
| 131 | else { |
||
| 132 | $arrResult[] = $Deal; |
||
| 133 | } |
||
| 134 | } |
||
| 135 | |||
| 136 | return $arrResult; |
||
| 137 | */ |
||
| 138 | |||
| 139 | return array(); |
||
| 140 | |||
| 141 | } |
||
| 142 | |||
| 196 |