Completed
Push — master ( dd5a10...89437c )
by Bukashk0zzz
03:55
created

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