Completed
Push — master ( 4a8227...2407ef )
by Bukashk0zzz
01:29
created

AbstractOffer::isPickup()   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 Bukashk0zzzYmlGenerator
5
 *
6
 * (c) Denis Golubovskiy <[email protected]>
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 Bukashk0zzz\YmlGenerator\Model\Offer;
13
14
/**
15
 * Abstract Class Offer
16
 */
17
abstract class AbstractOffer implements OfferInterface
18
{
19
    /**
20
     * @var string
21
     */
22
    private $id;
23
24
    /**
25
     * @var bool
26
     */
27
    private $available;
28
29
    /**
30
     * @var string
31
     */
32
    private $url;
33
34
    /**
35
     * @var float
36
     */
37
    private $price;
38
39
    /**
40
     * @var string
41
     */
42
    private $currencyId;
43
44
    /**
45
     * @var int
46
     */
47
    private $categoryId;
48
49
    /**
50
     * @var bool
51
     */
52
    private $adult;
53
54
    /**
55
     * @var string
56
     */
57
    private $salesNotes;
58
59
    /**
60
     * @var bool
61
     */
62
    private $manufacturerWarranty;
63
64
    /**
65
     * @var bool
66
     */
67
    private $pickup;
68
69
    /**
70
     * @var bool
71
     */
72
    private $downloadable;
73
74
    /**
75
     * @var bool
76
     */
77
    private $delivery;
78
79
    /**
80
     * @var float
81
     */
82
    private $localDeliveryCost;
83
84
    /**
85
     * @var string
86
     */
87
    private $description;
88
89
    /**
90
     * @var string
91
     */
92
    private $countryOfOrigin;
93
94
    /**
95
     * @var array
96
     */
97
    private $pictures = [];
98
99
    /**
100
     * @var array
101
     */
102
    private $params = [];
103
104
    /**
105
     * @return array
106
     */
107
    public function toArray()
108
    {
109
        return \array_merge($this->getHeaderOptions(), $this->getOptions(), $this->getFooterOptions());
110
    }
111
112
    /**
113
     * @return string
114
     */
115
    public function getId()
116
    {
117
        return $this->id;
118
    }
119
120
    /**
121
     * @param string $id
122
     *
123
     * @return $this
124
     */
125
    public function setId($id)
126
    {
127
        $this->id = $id;
128
129
        return $this;
130
    }
131
132
    /**
133
     * @return bool
134
     */
135
    public function isAvailable()
136
    {
137
        return $this->available;
138
    }
139
140
    /**
141
     * @param bool $available
142
     *
143
     * @return $this
144
     */
145
    public function setAvailable($available)
146
    {
147
        $this->available = $available;
148
149
        return $this;
150
    }
151
152
    /**
153
     * @return string
154
     */
155
    public function getUrl()
156
    {
157
        return $this->url;
158
    }
159
160
    /**
161
     * @param string $url
162
     *
163
     * @return $this
164
     */
165
    public function setUrl($url)
166
    {
167
        $this->url = $url;
168
169
        return $this;
170
    }
171
172
    /**
173
     * @return float
174
     */
175
    public function getPrice()
176
    {
177
        return $this->price;
178
    }
179
180
    /**
181
     * @param float $price
182
     *
183
     * @return $this
184
     */
185
    public function setPrice($price)
186
    {
187
        $this->price = $price;
188
189
        return $this;
190
    }
191
192
    /**
193
     * @return string
194
     */
195
    public function getCurrencyId()
196
    {
197
        return $this->currencyId;
198
    }
199
200
    /**
201
     * @param string $currencyId
202
     *
203
     * @return $this
204
     */
205
    public function setCurrencyId($currencyId)
206
    {
207
        $this->currencyId = $currencyId;
208
209
        return $this;
210
    }
211
212
    /**
213
     * @return int
214
     */
215
    public function getCategoryId()
216
    {
217
        return $this->categoryId;
218
    }
219
220
    /**
221
     * @param int $categoryId
222
     *
223
     * @return $this
224
     */
225
    public function setCategoryId($categoryId)
226
    {
227
        $this->categoryId = $categoryId;
228
229
        return $this;
230
    }
231
232
    /**
233
     * @return bool
234
     */
235
    public function isAdult()
236
    {
237
        return $this->adult;
238
    }
239
240
    /**
241
     * @param bool $adult
242
     *
243
     * @return $this
244
     */
245
    public function setAdult($adult)
246
    {
247
        $this->adult = $adult;
248
249
        return $this;
250
    }
251
252
    /**
253
     * @return string
254
     */
255
    public function getSalesNotes()
256
    {
257
        return $this->salesNotes;
258
    }
259
260
    /**
261
     * @param string $salesNotes
262
     *
263
     * @return $this
264
     */
265
    public function setSalesNotes($salesNotes)
266
    {
267
        $this->salesNotes = $salesNotes;
268
269
        return $this;
270
    }
271
272
    /**
273
     * @return bool
274
     */
275
    public function isManufacturerWarranty()
276
    {
277
        return $this->manufacturerWarranty;
278
    }
279
280
    /**
281
     * @param bool $manufacturerWarranty
282
     *
283
     * @return $this
284
     */
285
    public function setManufacturerWarranty($manufacturerWarranty)
286
    {
287
        $this->manufacturerWarranty = $manufacturerWarranty;
288
289
        return $this;
290
    }
291
292
    /**
293
     * @return bool
294
     */
295
    public function isPickup()
296
    {
297
        return $this->pickup;
298
    }
299
300
    /**
301
     * @param bool $pickup
302
     *
303
     * @return $this
304
     */
305
    public function setPickup($pickup)
306
    {
307
        $this->pickup = $pickup;
308
309
        return $this;
310
    }
311
312
    /**
313
     * @return bool
314
     */
315
    public function isDownloadable()
316
    {
317
        return $this->downloadable;
318
    }
319
320
    /**
321
     * @param bool $downloadable
322
     *
323
     * @return $this
324
     */
325
    public function setDownloadable($downloadable)
326
    {
327
        $this->downloadable = $downloadable;
328
329
        return $this;
330
    }
331
332
    /**
333
     * @return bool
334
     */
335
    public function isDelivery()
336
    {
337
        return $this->delivery;
338
    }
339
340
    /**
341
     * @param bool $delivery
342
     *
343
     * @return $this
344
     */
345
    public function setDelivery($delivery)
346
    {
347
        $this->delivery = $delivery;
348
349
        return $this;
350
    }
351
352
    /**
353
     * @return float
354
     */
355
    public function getLocalDeliveryCost()
356
    {
357
        return $this->localDeliveryCost;
358
    }
359
360
    /**
361
     * @param float $localDeliveryCost
362
     *
363
     * @return $this
364
     */
365
    public function setLocalDeliveryCost($localDeliveryCost)
366
    {
367
        $this->localDeliveryCost = $localDeliveryCost;
368
369
        return $this;
370
    }
371
372
    /**
373
     * @return string
374
     */
375
    public function getDescription()
376
    {
377
        return $this->description;
378
    }
379
380
    /**
381
     * @param string $description
382
     *
383
     * @return $this
384
     */
385
    public function setDescription($description)
386
    {
387
        $this->description = $description;
388
389
        return $this;
390
    }
391
392
    /**
393
     * @return string
394
     */
395
    public function getCountryOfOrigin()
396
    {
397
        return $this->countryOfOrigin;
398
    }
399
400
    /**
401
     * @param string $countryOfOrigin
402
     *
403
     * @return $this
404
     */
405
    public function setCountryOfOrigin($countryOfOrigin)
406
    {
407
        $this->countryOfOrigin = $countryOfOrigin;
408
409
        return $this;
410
    }
411
412
    /**
413
     * @return array
414
     */
415
    public function getParams()
416
    {
417
        return $this->params;
418
    }
419
420
    /**
421
     * @param OfferParam $param
422
     *
423
     * @return $this
424
     */
425
    public function addParam(OfferParam $param)
426
    {
427
        $this->params[] = $param;
428
429
        return $this;
430
    }
431
432
    /**
433
     * Add picture
434
     *
435
     * @param string $url
436
     *
437
     * @return $this
438
     */
439
    public function addPicture($url)
440
    {
441
        if (\count($this->pictures) < 10) {
442
            $this->pictures[] = $url;
443
        }
444
445
        return $this;
446
    }
447
448
    /**
449
     * Set pictures
450
     *
451
     * @param array $pictures
452
     *
453
     * @return $this
454
     */
455
    public function setPictures(array $pictures)
456
    {
457
        $this->pictures = $pictures;
458
459
        return $this;
460
    }
461
462
    /**
463
     * Get picture list
464
     *
465
     * @return array
466
     */
467
    public function getPictures()
468
    {
469
        return $this->pictures;
470
    }
471
472
    /**
473
     * @return array
474
     */
475
    abstract protected function getOptions();
476
477
    /**
478
     * @return array
479
     */
480
    private function getHeaderOptions()
481
    {
482
        return [
483
            'url' => $this->getUrl(),
484
            'price' => $this->getPrice(),
485
            'currencyId' => $this->getCurrencyId(),
486
            'categoryId' => $this->getCategoryId(),
487
            'picture' => $this->getPictures(),
488
            'pickup' => $this->isPickup(),
489
            'delivery' => $this->isDelivery(),
490
            'local_delivery_cost' => $this->getLocalDeliveryCost(),
491
        ];
492
    }
493
494
    /**
495
     * @return array
496
     */
497
    private function getFooterOptions()
498
    {
499
        return [
500
            'description' => $this->getDescription(),
501
            'sales_notes' => $this->getSalesNotes(),
502
            'manufacturer_warranty' => $this->isManufacturerWarranty(),
503
            'country_of_origin' => $this->getCountryOfOrigin(),
504
            'downloadable' => $this->isDownloadable(),
505
            'adult' => $this->isAdult(),
506
        ];
507
    }
508
}
509