Division by zero.
This commit is contained in:
parent
deac9203bd
commit
e4bf3fd342
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Model;
|
namespace Model;
|
||||||
|
|
||||||
|
use Core\Config;
|
||||||
use Core\Db;
|
use Core\Db;
|
||||||
|
|
||||||
class EkrExchangeRates
|
class EkrExchangeRates
|
||||||
@ -14,23 +15,29 @@ class EkrExchangeRates
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->today = Db::getRow('select RUB, USD, from_unixtime(id, ?) as date from ekr_exchange_rates order by id desc limit 1', ['%d.%m.%Y']);
|
$this->today = Db::getRow('select RUB, USD, from_unixtime(id, ?) as date from ekr_exchange_rates order by id desc limit 1', ['%d.%m.%Y']);
|
||||||
if (empty($this->today)) {
|
|
||||||
$this->today = ['RUB' => 0, 'USD' => 0, 'date' => '00.00.0000'];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function oneEkrInUSD(): float
|
public function oneEkrInUSD(): float
|
||||||
{
|
{
|
||||||
|
if (!$this->today) {
|
||||||
|
return 0.00;
|
||||||
|
}
|
||||||
return round($this->today['RUB'] / $this->today['USD'], 2);
|
return round($this->today['RUB'] / $this->today['USD'], 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function oneEkrInRUB(): float
|
public function oneEkrInRUB(): float
|
||||||
{
|
{
|
||||||
|
if (!$this->today) {
|
||||||
|
return floatval(Config::EKR_RUB_PRICE);
|
||||||
|
}
|
||||||
return $this->today['RUB'];
|
return $this->today['RUB'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function date(): string
|
public function date(): string
|
||||||
{
|
{
|
||||||
|
if (!$this->today) {
|
||||||
|
return date('d.m.Y');
|
||||||
|
}
|
||||||
return $this->today['date'];
|
return $this->today['date'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user