| Total Complexity | 9 |
| Total Lines | 102 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | class Conversion |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var string |
||
| 12 | */ |
||
| 13 | private $fromCurrency; |
||
| 14 | /** |
||
| 15 | * @var string |
||
| 16 | */ |
||
| 17 | private $toCurrency; |
||
| 18 | /** |
||
| 19 | * @var int|float |
||
| 20 | */ |
||
| 21 | private $amount; |
||
| 22 | /** |
||
| 23 | * @var CarbonImmutable |
||
| 24 | */ |
||
| 25 | private $timestamp; |
||
| 26 | /** |
||
| 27 | * @var float |
||
| 28 | */ |
||
| 29 | private $quote; |
||
| 30 | /** |
||
| 31 | * @var float |
||
| 32 | */ |
||
| 33 | private $result; |
||
| 34 | /** |
||
| 35 | * @var CarbonImmutable|null |
||
| 36 | */ |
||
| 37 | private $date; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Conversion constructor. |
||
| 41 | * |
||
| 42 | * @param array $data |
||
| 43 | * @throws \Exception |
||
| 44 | */ |
||
| 45 | public function __construct(array $data) |
||
| 46 | { |
||
| 47 | $this->fromCurrency = $data['query']['from']; |
||
| 48 | $this->toCurrency = $data['query']['to']; |
||
| 49 | $this->amount = $data['query']['amount']; |
||
| 50 | $this->quote = $data['info']['quote']; |
||
| 51 | $this->result = $data['result']; |
||
| 52 | $this->timestamp = new CarbonImmutable($data['info']['timestamp']); |
||
| 53 | $this->date = isset($data['date']) ? new CarbonImmutable($data['date']) : null; |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @return string |
||
| 58 | */ |
||
| 59 | public function getFromCurrency(): string |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @return string |
||
| 66 | */ |
||
| 67 | public function getToCurrency(): string |
||
| 70 | } |
||
| 71 | |||
| 72 | /** |
||
| 73 | * @return float|int |
||
| 74 | */ |
||
| 75 | public function getAmount() |
||
| 76 | { |
||
| 77 | return $this->amount; |
||
| 78 | } |
||
| 79 | |||
| 80 | /** |
||
| 81 | * @return DateTimeImmutable |
||
| 82 | */ |
||
| 83 | public function getTimestamp(): DateTimeImmutable |
||
| 86 | } |
||
| 87 | |||
| 88 | /** |
||
| 89 | * @return float |
||
| 90 | */ |
||
| 91 | public function getQuote(): float |
||
| 92 | { |
||
| 93 | return $this->quote; |
||
| 94 | } |
||
| 95 | |||
| 96 | /** |
||
| 97 | * @return float |
||
| 98 | */ |
||
| 99 | public function getResult(): float |
||
| 102 | } |
||
| 103 | |||
| 104 | /** |
||
| 105 | * @return CarbonImmutable|null |
||
| 106 | */ |
||
| 107 | public function getDate(): ?CarbonImmutable |
||
| 110 | } |
||
| 111 | } |
||
| 112 |