Refactor getPrice() in tools.class.php
$this->config['currency'] as $strBase $this->config['price']['currency'] as $strQuote
This commit is contained in:
parent
97b3cc3b50
commit
de6fbf88db
@ -97,7 +97,8 @@ class Tools extends Base {
|
|||||||
**/
|
**/
|
||||||
public function getPrice() {
|
public function getPrice() {
|
||||||
$aData = $this->getApi($this->config['price']['url'], $this->config['price']['target']);
|
$aData = $this->getApi($this->config['price']['url'], $this->config['price']['target']);
|
||||||
$strCurrency = $this->config['currency'];
|
$strBase = $this->config['currency'];
|
||||||
|
$strQuote = $this->config['price']['currency'];
|
||||||
// Check the API type for configured URL
|
// Check the API type for configured URL
|
||||||
if (!$strApiType = $this->getApiType($this->config['price']['url']))
|
if (!$strApiType = $this->getApiType($this->config['price']['url']))
|
||||||
return false;
|
return false;
|
||||||
@ -106,7 +107,7 @@ class Tools extends Base {
|
|||||||
switch ($strApiType) {
|
switch ($strApiType) {
|
||||||
case 'coinchose':
|
case 'coinchose':
|
||||||
foreach ($aData as $aItem) {
|
foreach ($aData as $aItem) {
|
||||||
if($strCurrency == $aItem[0])
|
if($strBase == $aItem[0])
|
||||||
return $aItem['price'];
|
return $aItem['price'];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -114,13 +115,13 @@ class Tools extends Base {
|
|||||||
return $aData['ticker']['last'];
|
return $aData['ticker']['last'];
|
||||||
break;
|
break;
|
||||||
case 'cryptsy':
|
case 'cryptsy':
|
||||||
return @$aData['return']['markets'][$strCurrency]['lasttradeprice'];
|
return @$aData['return']['markets'][$strBase]['lasttradeprice'];
|
||||||
break;
|
break;
|
||||||
case 'cryptopia':
|
case 'cryptopia':
|
||||||
return @$aData['Data']['LastPrice'];
|
return @$aData['Data']['LastPrice'];
|
||||||
break;
|
break;
|
||||||
case 'cryptorush':
|
case 'cryptorush':
|
||||||
return @$aData["$strCurrency/" . $this->config['price']['currency']]['last_trade'];
|
return @$aData["{$strBase}/{$strQuote}"]['last_trade'];
|
||||||
break;
|
break;
|
||||||
case 'mintpal':
|
case 'mintpal':
|
||||||
return @$aData['0']['last_price'];
|
return @$aData['0']['last_price'];
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user