Completed
Push — master ( 175f05...5ac193 )
by Bukashk0zzz
04:34
created

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