Item::getId()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace WSW\SiftScience\Entities;
4
5
use WSW\Money\Money;
6
7
/**
8
 * Class Item
9
 *
10
 * @package WSW\SiftScience\Entities
11
 * @author Ronaldo Matos Rodrigues <[email protected]>
12
 */
13
class Item
14
{
15
    /**
16
     * @var string
17
     */
18
    private $id;
19
20
    /**
21
     * @var string
22
     */
23
    private $title;
24
25
    /**
26
     * @var Money
27
     */
28
    private $price;
29
30
    /**
31
     * @var string
32
     */
33
    private $upc;
34
    /**
35
     * @var string
36
     */
37
    private $sku;
38
39
    /**
40
     * @var string
41
     */
42
    private $brand;
43
44
    /**
45
     * @var string
46
     */
47
    private $manufacturer;
48
49
    /**
50
     * @var string
51
     */
52
    private $category;
53
54
    /**
55
     * @var array
56
     */
57
    private $tags;
58
59
    /**
60
     * @var string
61
     */
62
    private $color;
63
64
    /**
65
     * @var int
66
     */
67
    private $quantity;
68
69
    /**
70
     * @return string
71
     */
72 2
    public function getId()
73
    {
74 2
        return $this->id;
75
    }
76
77
    /**
78
     * @param string $id
79
     *
80
     * @return Item
81
     */
82 4
    public function setId($id)
83
    {
84 4
        $this->id = $id;
85
86 4
        return $this;
87
    }
88
89
    /**
90
     * @return string
91
     */
92 2
    public function getTitle()
93
    {
94 2
        return $this->title;
95
    }
96
97
    /**
98
     * @param string $title
99
     *
100
     * @return Item
101
     */
102 4
    public function setTitle($title)
103
    {
104 4
        $this->title = $title;
105
106 4
        return $this;
107
    }
108
109
    /**
110
     * @return Money
111
     */
112 3
    public function getPrice()
113
    {
114 3
        return $this->price;
115
    }
116
117
    /**
118
     * @param Money $price
119
     *
120
     * @return Item
121
     */
122 4
    public function setPrice(Money $price)
123
    {
124 4
        $this->price = $price;
125
126 4
        return $this;
127
    }
128
129
    /**
130
     * @return string
131
     */
132 2
    public function getUpc()
133
    {
134 2
        return $this->upc;
135
    }
136
137
    /**
138
     * @param string $upc
139
     *
140
     * @return Item
141
     */
142 4
    public function setUpc($upc)
143
    {
144 4
        $this->upc = $upc;
145
146 4
        return $this;
147
    }
148
149
    /**
150
     * @return string
151
     */
152 2
    public function getSku()
153
    {
154 2
        return $this->sku;
155
    }
156
157
    /**
158
     * @param string $sku
159
     *
160
     * @return Item
161
     */
162 4
    public function setSku($sku)
163
    {
164 4
        $this->sku = $sku;
165
166 4
        return $this;
167
    }
168
169
    /**
170
     * @return string
171
     */
172 2
    public function getBrand()
173
    {
174 2
        return $this->brand;
175
    }
176
177
    /**
178
     * @param string $brand
179
     *
180
     * @return Item
181
     */
182 4
    public function setBrand($brand)
183
    {
184 4
        $this->brand = $brand;
185
186 4
        return $this;
187
    }
188
189
    /**
190
     * @return string
191
     */
192 2
    public function getManufacturer()
193
    {
194 2
        return $this->manufacturer;
195
    }
196
197
    /**
198
     * @param string $manufacturer
199
     *
200
     * @return Item
201
     */
202 4
    public function setManufacturer($manufacturer)
203
    {
204 4
        $this->manufacturer = $manufacturer;
205
206 4
        return $this;
207
    }
208
209
    /**
210
     * @return string
211
     */
212 2
    public function getCategory()
213
    {
214 2
        return $this->category;
215
    }
216
217
    /**
218
     * @param string $category
219
     *
220
     * @return Item
221
     */
222 4
    public function setCategory($category)
223
    {
224 4
        $this->category = $category;
225
226 4
        return $this;
227
    }
228
229
    /**
230
     * @return array
231
     */
232 2
    public function getTags()
233
    {
234 2
        return $this->tags;
235
    }
236
237
    /**
238
     * @param array $tags
239
     *
240
     * @return Item
241
     */
242 4
    public function setTags(array $tags)
243
    {
244 4
        $this->tags = $tags;
245
246 4
        return $this;
247
    }
248
249
    /**
250
     * @return string
251
     */
252 2
    public function getColor()
253
    {
254 2
        return $this->color;
255
    }
256
257
    /**
258
     * @param string $color
259
     *
260
     * @return Item
261
     */
262 3
    public function setColor($color)
263
    {
264 3
        $this->color = $color;
265
266 3
        return $this;
267
    }
268
269
    /**
270
     * @return int
271
     */
272 3
    public function getQuantity()
273
    {
274 3
        return $this->quantity;
275
    }
276
277
    /**
278
     * @param int $quantity
279
     *
280
     * @return Item
281
     */
282 4
    public function setQuantity($quantity)
283
    {
284 4
        $this->quantity = (int) $quantity;
285
286 4
        return $this;
287
    }
288
289
    /**
290
     * @return Money
291
     */
292 1
    public function getTotalAmount()
293
    {
294 1
        $newAmount = bcmul($this->getPrice()->getAmount(), $this->getQuantity(), Money::SCALE);
295
296 1
        return $this->getPrice()->newInstance($newAmount);
297
    }
298
}
299