for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Orkhanahmadov\Currencylayer\Data;
class Conversion
{
/**
* @var string
*/
private $fromCurrency;
private $toCurrency;
* @var \DateTimeInterface|null
private $date = null;
* @var int|float
private $amount;
* @var int
private $timestamp;
* @var float
private $quote;
private $result;
* Conversion constructor.
*
* @param array $data
* @throws \Exception
public function __construct(array $data)
$this->fromCurrency = $data['query']['from'];
$this->toCurrency = $data['query']['to'];
$this->amount = $data['query']['amount'];
$this->quote = $data['info']['quote'];
$this->result = $data['result'];
$this->timestamp = $data['info']['timestamp'];
$this->date = isset($data['date']) ? new \DateTimeImmutable($data['date']) : null;
}
* @return string
public function fromCurrency(): string
return $this->fromCurrency;
public function toCurrency(): string
return $this->toCurrency;
* @return \DateTimeInterface|null
public function date(): ?\DateTimeInterface
return $this->date;
* @return float|int
public function amount()
return $this->amount;
* @return int
public function timestamp(): int
return $this->timestamp;
* @return float
public function quote(): float
return $this->quote;
public function result(): float
return $this->result;