Completed
Push — master ( 388511...ed7ca5 )
by Bukashk0zzz
14s
created

AbstractOffer::setMarketCategory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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