Completed
Push — master ( ed7ca5...73010b )
by Bukashk0zzz
14s queued 10s
created

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