Completed
Push — master ( 2af63f...bfd93b )
by Paweł
76:32 queued 64:10
created

ExchangeRate::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sylius\Component\Currency\Model;
13
14
use Sylius\Component\Resource\Model\TimestampableTrait;
15
use Webmozart\Assert\Assert;
16
17
/**
18
 * @author Jan Góralski <[email protected]>
19
 */
20
class ExchangeRate implements ExchangeRateInterface
21
{
22
    use TimestampableTrait;
23
24
    /**
25
     * @var mixed
26
     */
27
    protected $id;
28
29
    /**
30
     * @var float
31
     */
32
    protected $ratio;
33
34
    /**
35
     * @var CurrencyInterface
36
     */
37
    protected $sourceCurrency;
38
39
    /**
40
     * @var CurrencyInterface
41
     */
42
    protected $targetCurrency;
43
44
    public function __construct()
45
    {
46
        $this->createdAt = new \DateTime();
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function getId()
53
    {
54
        return $this->id;
55
    }
56
57
    /**
58
     * {@inheritdoc}
59
     */
60
    public function getRatio()
61
    {
62
        return $this->ratio;
63
    }
64
65
    /**
66
     * {@inheritdoc}
67
     *
68
     * @throws \InvalidArgumentException
69
     */
70
    public function setRatio($ratio)
71
    {
72
        Assert::nullOrFloat($ratio);
73
74
        $this->ratio = $ratio;
75
    }
76
77
    /**
78
     * {@inheritdoc}
79
     */
80
    public function getSourceCurrency()
81
    {
82
        return $this->sourceCurrency;
83
    }
84
85
    /**
86
     * {@inheritdoc}
87
     */
88
    public function setSourceCurrency(CurrencyInterface $currency)
89
    {
90
        $this->sourceCurrency = $currency;
91
    }
92
93
    /**
94
     * {@inheritdoc}
95
     */
96
    public function getTargetCurrency()
97
    {
98
        return $this->targetCurrency;
99
    }
100
101
    /**
102
     * {@inheritdoc}
103
     */
104
    public function setTargetCurrency(CurrencyInterface $currency)
105
    {
106
        $this->targetCurrency = $currency;
107
    }
108
}
109