Completed
Push — master ( 73010b...8cdd3c )
by Bukashk0zzz
02:07
created

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