Currency::setUpdatedAt()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @author Rafał Muszyński <[email protected]>
5
 * @copyright 2015 Sourcefabric z.ú.
6
 * @license http://www.gnu.org/licenses/gpl-3.0.txt
7
 */
8
9
namespace Newscoop\PaywallBundle\Entity;
10
11
use Doctrine\ORM\Mapping as ORM;
12
use Newscoop\PaywallBundle\Validator\Constraints as PaywallValidators;
13
use Sylius\Component\Currency\Model\CurrencyInterface;
14
use Symfony\Component\Intl\Intl;
15
16
/**
17
 * Currency entity.
18
 *
19
 * @ORM\Entity(repositoryClass="Newscoop\PaywallBundle\Entity\Repository\CurrencyRepository")
20
 * @ORM\Table(name="plugin_paywall_currency")
21
 */
22
class Currency implements CurrencyInterface
23
{
24
    /**
25
     * @ORM\Id
26
     * @ORM\GeneratedValue
27
     * @ORM\Column(type="integer", name="id")
28
     *
29
     * @var int
30
     */
31
    protected $id;
32
33
    /**
34
     * @ORM\Column(type="string", name="currency_code")
35
     *
36
     * @var string
37
     */
38
    protected $code;
39
40
    /**
41
     * @PaywallValidators\ContainsDecimal(entity="Currency", property="exchangeRate")
42
     * @ORM\Column(type="decimal", name="exchange_rate", precision=10, scale=5)
43
     *
44
     * @var float
45
     */
46
    protected $exchangeRate;
47
48
    /**
49
     * @ORM\Column(type="boolean", name="is_active")
50
     *
51
     * @var bool
52
     */
53
    protected $isActive = false;
54
55
    /**
56
     * @ORM\Column(type="boolean", name="is_default")
57
     *
58
     * @var bool
59
     */
60
    protected $default = false;
61
62
    /**
63
     * @ORM\Column(type="datetime", name="updated_at", nullable=true)
64
     *
65
     * @var \DateTime
66
     */
67
    protected $updatedAt;
68
69
    /**
70
     * @ORM\Column(type="datetime", name="created_at")
71
     *
72
     * @var \DateTime
73
     */
74
    protected $createdAt;
75
76
    /**
77
     * Constructor.
78
     */
79
    public function __construct()
80
    {
81
        $this->createdAt = new \DateTime();
82
    }
83
84
    /**
85
     * Gets the value of id.
86
     *
87
     * @return int
88
     */
89
    public function getId()
90
    {
91
        return $this->id;
92
    }
93
94
    /**
95
     * Sets the value of id.
96
     *
97
     * @param int $id the id
98
     *
99
     * @return self
100
     */
101
    public function setId($id)
102
    {
103
        $this->id = $id;
104
105
        return $this;
106
    }
107
108
    /**
109
     * {@inheritdoc}
110
     */
111
    public function getName()
112
    {
113
        return Intl::getCurrencyBundle()->getCurrencyName($this->code);
114
    }
115
116
    /**
117
     * {@inheritdoc}
118
     */
119
    public function getCode()
120
    {
121
        return $this->code;
122
    }
123
124
    /**
125
     * {@inheritdoc}
126
     */
127
    public function setCode($code)
128
    {
129
        $this->code = $code;
130
131
        return $this;
132
    }
133
134
    /**
135
     * {@inheritdoc}
136
     */
137
    public function getExchangeRate()
138
    {
139
        return $this->exchangeRate;
140
    }
141
142
    /**
143
     * {@inheritdoc}
144
     */
145
    public function setExchangeRate($rate)
146
    {
147
        $this->exchangeRate = $rate;
148
149
        return $this;
150
    }
151
152
    /**
153
     * {@inheritdoc}
154
     */
155
    public function isEnabled()
156
    {
157
        return $this->isActive;
158
    }
159
160
    public function getIsActive()
161
    {
162
        return $this->isEnabled();
163
    }
164
165
    public function setIsActive($isActive)
166
    {
167
        $this->setEnabled($isActive);
168
    }
169
170
    /**
171
     * {@inheritdoc}
172
     */
173
    public function setEnabled($enabled)
174
    {
175
        $this->isActive = (Boolean) $enabled;
176
    }
177
178
    /**
179
     * {@inheritdoc}
180
     */
181
    public function getCreatedAt()
182
    {
183
        return $this->createdAt;
184
    }
185
186
    /**
187
     * {@inheritdoc}
188
     */
189
    public function setCreatedAt(\DateTime $createdAt)
190
    {
191
        $this->createdAt = $createdAt;
192
193
        return $this;
194
    }
195
196
    /**
197
     * {@inheritdoc}
198
     */
199
    public function getUpdatedAt()
200
    {
201
        return $this->updatedAt;
202
    }
203
    /**
204
     * {@inheritdoc}
205
     */
206
    public function setUpdatedAt(\DateTime $updatedAt)
207
    {
208
        $this->updatedAt = $updatedAt;
209
210
        return $this;
211
    }
212
213
    /**
214
     * Gets the value of default.
215
     *
216
     * @return bool
217
     */
218
    public function getDefault()
219
    {
220
        return $this->default;
221
    }
222
223
    /**
224
     * Sets the value of default.
225
     *
226
     * @param bool $default the default
227
     *
228
     * @return self
229
     */
230
    public function setDefault($default)
231
    {
232
        $this->default = $default;
233
234
        return $this;
235
    }
236
}
237