Completed
Push — master ( 4f3285...cedc69 )
by Ronaldo
02:00
created

CreateOrder::setBillingAddress()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
namespace WSW\SiftScience\Events;
4
5
use InvalidArgumentException;
6
use WSW\Email\Email;
7
use WSW\Money\Money;
8
use WSW\SiftScience\Collections\Items;
9
use WSW\SiftScience\Collections\PaymentMethods;
10
use WSW\SiftScience\Collections\Promotions;
11
use WSW\SiftScience\Entities\Address;
12
use WSW\SiftScience\Entities\Item;
13
use WSW\SiftScience\Entities\PaymentMethod;
14
use WSW\SiftScience\Entities\Promotion;
15
use WSW\SiftScience\Support\AllowedValues\ShippingMethod;
16
17
/**
18
 * Class CreateOrder
19
 *
20
 * @package WSW\SiftScience\Events
21
 * @author Ronaldo Matos Rodrigues <[email protected]>
22
 */
23
class CreateOrder extends BaseEvent
24
{
25
    /**
26
     * @var string
27
     */
28
    private $session;
29
30
    /**
31
     * @var string
32
     */
33
    private $order;
34
35
    /**
36
     * @var Email
37
     */
38
    private $userEmail;
39
40
    /**
41
     * @var Money
42
     */
43
    private $amount;
44
45
    /**
46
     * @var Address
47
     */
48
    private $billingAddress;
49
50
    /**
51
     * @var PaymentMethods
52
     */
53
    private $paymentMethods;
54
55
    /**
56
     * @var Address
57
     */
58
    private $shippingAddress;
59
60
    /**
61
     * @var bool
62
     */
63
    private $expeditedShipping = false;
64
65
    /**
66
     * @var string
67
     */
68
    private $shippingMethod;
69
70
    /**
71
     * @var Items
72
     */
73
    private $items;
74
75
    /**
76
     * @var string
77
     */
78
    private $sellerUserId;
79
80
    /**
81
     * @var Promotions
82
     */
83
    private $promotions;
84
85
    /**
86
     * CreateOrder constructor.
87
     */
88 5
    public function __construct()
89
    {
90 5
        $this->type = '$create_order';
91 5
        $this->items = new Items();
92 5
        $this->paymentMethods = new PaymentMethods();
93 5
        $this->promotions = new Promotions();
94 5
    }
95
96
    /**
97
     * @return string
98
     */
99 1
    public function getSession()
100
    {
101 1
        return $this->session;
102
    }
103
104
    /**
105
     * @param string $session
106
     *
107
     * @return $this
108
     */
109 1
    public function setSession($session)
110
    {
111 1
        $this->session = $session;
112
113 1
        return $this;
114
    }
115
116
    /**
117
     * @return string
118
     */
119 1
    public function getOrder()
120
    {
121 1
        return $this->order;
122
    }
123
124
    /**
125
     * @param string $order
126
     *
127
     * @return $this
128
     */
129 1
    public function setOrder($order)
130
    {
131 1
        $this->order = $order;
132
133 1
        return $this;
134
    }
135
136
    /**
137
     * @return Email
138
     */
139 1
    public function getUserEmail()
140
    {
141 1
        return $this->userEmail;
142
    }
143
144
    /**
145
     * @param Email $userEmail
146
     *
147
     * @return $this
148
     */
149 1
    public function setUserEmail(Email $userEmail)
150
    {
151 1
        $this->userEmail = $userEmail;
152
153 1
        return $this;
154
    }
155
156
    /**
157
     * @return Money
158
     */
159 1
    public function getAmount()
160
    {
161 1
        return $this->amount;
162
    }
163
164
    /**
165
     * @param Money $amount
166
     *
167
     * @return $this
168
     */
169 1
    public function setAmount(Money $amount)
170
    {
171 1
        $this->amount = $amount;
172
173 1
        return $this;
174
    }
175
176
    /**
177
     * @return Address
178
     */
179 1
    public function getBillingAddress()
180
    {
181 1
        return $this->billingAddress;
182
    }
183
184
    /**
185
     * @param Address $billingAddress
186
     *
187
     * @return $this
188
     */
189 1
    public function setBillingAddress(Address $billingAddress)
190
    {
191 1
        $this->billingAddress = $billingAddress;
192
193 1
        return $this;
194
    }
195
196
    /**
197
     * @return PaymentMethods
198
     */
199 1
    public function getPaymentMethods()
200
    {
201 1
        return $this->paymentMethods;
202
    }
203
204
    /**
205
     * @param PaymentMethod $paymentMethod
206
     *
207
     * @return $this
208
     */
209 1
    public function addPaymentMethod(PaymentMethod $paymentMethod)
210
    {
211 1
        $this->paymentMethods->add($paymentMethod);
212
213 1
        return $this;
214
    }
215
216
    /**
217
     * @return Address
218
     */
219 1
    public function getShippingAddress()
220
    {
221 1
        return $this->shippingAddress;
222
    }
223
224
    /**
225
     * @param Address $shippingAddress
226
     *
227
     * @return $this
228
     */
229 1
    public function setShippingAddress(Address $shippingAddress)
230
    {
231 1
        $this->shippingAddress = $shippingAddress;
232
233 1
        return $this;
234
    }
235
236
    /**
237
     * @return bool
238
     */
239 1
    public function isExpeditedShipping()
240
    {
241 1
        return (bool) $this->expeditedShipping;
242
    }
243
244
    /**
245
     * @param bool $expeditedShipping
246
     *
247
     * @return $this
248
     */
249 1
    public function setExpeditedShipping($expeditedShipping)
250
    {
251 1
        $this->expeditedShipping = (bool) $expeditedShipping;
252
253 1
        return $this;
254
    }
255
256
    /**
257
     * @return string
258
     */
259 1
    public function getShippingMethod()
260
    {
261 1
        return $this->shippingMethod;
262
    }
263
264
    /**
265
     * @param string $shippingMethod
266
     *
267
     * @return $this
268
     */
269 2
    public function setShippingMethod($shippingMethod)
270
    {
271 2
        if (!ShippingMethod::isValid($shippingMethod)) {
272 1
            throw new InvalidArgumentException('You should inform a valid shipping method.');
273
        }
274
275 1
        $this->shippingMethod = $shippingMethod;
276
277 1
        return $this;
278
    }
279
280
    /**
281
     * @return Items
282
     */
283 1
    public function getItems()
284
    {
285 1
        return $this->items;
286
    }
287
288
    /**
289
     * @param Item $item
290
     *
291
     * @return $this
292
     */
293 1
    public function addItem(Item $item)
294
    {
295 1
        $this->items->add($item);
296
297 1
        return $this;
298
    }
299
300
    /**
301
     * @return string
302
     */
303 1
    public function getSellerUserId()
304
    {
305 1
        return $this->sellerUserId;
306
    }
307
308
    /**
309
     * @param string $sellerUserId
310
     *
311
     * @return $this
312
     */
313 1
    public function setSellerUserId($sellerUserId)
314
    {
315 1
        $this->sellerUserId = $sellerUserId;
316
317 1
        return $this;
318
    }
319
320
    /**
321
     * @return Promotions
322
     */
323 1
    public function getPromotions()
324
    {
325 1
        return $this->promotions;
326
    }
327
328
    /**
329
     * @param Promotion $promotion
330
     *
331
     * @return $this
332
     */
333 1
    public function addPromotion(Promotion $promotion)
334
    {
335 1
        $this->promotions->add($promotion);
336
337 1
        return $this;
338
    }
339
}
340