Rate::getDate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Movavi\Entity;
4
5
/**
6
 * Class Rate
7
 *
8
 * Class-entity for currency rate
9
 *
10
 * @package Movavi\Entity
11
 */
12
class Rate
13
{
14
    /**
15
     * Field, contains convertible currency alias
16
     *
17
     * @var string
18
     */
19
    public $currencyFrom;
20
21
    /**
22
     * Field, contains reference currency alias
23
     *
24
     * @var string
25
     */
26
    public $currencyTo;
27
28
    /**
29
     * Rate value
30
     *
31
     * @var float
32
     */
33
    public $rate;
34
35
    /**
36
     * Date of rate
37
     *
38
     * @var \DateTime
39
     */
40
    public $date;
41
42
    /**
43
     * Rate constructor.
44
     *
45
     * @param string $currencyFrom
46
     * @param string $currencyTo
47
     * @param \DateTime $date
48
     * @param float $rate
49
     */
50
    public function __construct(string $currencyFrom, string $currencyTo, \DateTime $date, float $rate)
51
    {
52
        $this->currencyFrom = $currencyFrom;
53
        $this->currencyTo = $currencyTo;
54
        $this->date = $date;
55
        $this->rate = $rate;
56
    }
57
58
    /**
59
     * Getter for currencyFrom
60
     *
61
     * @return string
62
     */
63
    public function getCurrencyFrom(): string
64
    {
65
        return $this->currencyFrom;
66
    }
67
68
    /**
69
     * Getter for currencyTo
70
     *
71
     * @return string
72
     */
73
    public function getCurrencyTo(): string
74
    {
75
        return $this->currencyTo;
76
    }
77
78
    /**
79
     * Getter for rate
80
     *
81
     * @return float
82
     */
83
    public function getRate(): float
84
    {
85
        return $this->rate;
86
    }
87
88
    /**
89
     * Getter for date
90
     *
91
     * @return \DateTime
92
     */
93
    public function getDate(): \DateTime
94
    {
95
        return $this->date;
96
    }
97
98
    /**
99
     * toString magic method
100
     *
101
     * @return string
102
     */
103
    public function __toString(): string
104
    {
105
        return sprintf(
106
            "%s to %s rate is %s on %s.",
107
            ucfirst($this->currencyFrom),
108
            $this->currencyTo,
109
            $this->rate,
110
            $this->date->format('Y-m-d')
111
        );
112
    }
113
}
114