Completed
Push — master ( 8e28ab...2236d8 )
by Taosikai
15:04
created

Fulfillment::setService()   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 slince/shopify-api-php
5
 *
6
 * (c) Taosikai <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Slince\Shopify\Manager\Fulfillment;
13
14
use Slince\Shopify\Common\Model\Model;
15
use Slince\Shopify\Hydrator\Association\HasMany;
16
use Slince\Shopify\Manager\Order\LineItem;
17
18
class Fulfillment extends Model
19
{
20
    /**
21
     * @var int
22
     */
23
    protected $orderId;
24
25
    /**
26
     * @var string
27
     */
28
    protected $status;
29
30
    /**
31
     * @var string
32
     */
33
    protected $createdAt;
34
35
    /**
36
     * @var string
37
     */
38
    protected $updatedAt;
39
40
    /**
41
     * @var string
42
     */
43
    protected $service;
44
45
    /**
46
     * @var string
47
     */
48
    protected $shipmentStatus;
49
50
    /**
51
     * @var string
52
     */
53
    protected $trackingCompany;
54
55
    /**
56
     * @var string
57
     */
58
    protected $trackingNumber;
59
60
    /**
61
     * @var array
62
     */
63
    protected $trackingNumbers;
64
65
    /**
66
     * @var string
67
     */
68
    protected $trackingUrl;
69
70
    /**
71
     * @var array
72
     */
73
    protected $trackingUrls;
74
75
    /**
76
     * @var array
77
     */
78
    protected $receipt;
79
80
    /**
81
     * @var LineItem[]
82
     */
83
    protected $lineItems;
84
85
    /**
86
     * @return string
87
     */
88
    public function getService()
89
    {
90
        return $this->service;
91
    }
92
93
    /**
94
     * @param string $service
95
     *
96
     * @return Fulfillment
97
     */
98
    public function setService($service)
99
    {
100
        $this->service = $service;
101
102
        return $this;
103
    }
104
105
    /**
106
     * @return string
107
     */
108
    public function getShipmentStatus()
109
    {
110
        return $this->shipmentStatus;
111
    }
112
113
    /**
114
     * @param string $shipmentStatus
115
     *
116
     * @return Fulfillment
117
     */
118
    public function setShipmentStatus($shipmentStatus)
119
    {
120
        $this->shipmentStatus = $shipmentStatus;
121
122
        return $this;
123
    }
124
125
    /**
126
     * @return string
127
     */
128
    public function getTrackingUrl()
129
    {
130
        return $this->trackingUrl;
131
    }
132
133
    /**
134
     * @param string $trackingUrl
135
     *
136
     * @return Fulfillment
137
     */
138
    public function setTrackingUrl($trackingUrl)
139
    {
140
        $this->trackingUrl = $trackingUrl;
141
142
        return $this;
143
    }
144
145
    /**
146
     * @return array
147
     */
148
    public function getTrackingUrls()
149
    {
150
        return $this->trackingUrls;
151
    }
152
153
    /**
154
     * @param array $trackingUrls
155
     *
156
     * @return Fulfillment
157
     */
158
    public function setTrackingUrls($trackingUrls)
159
    {
160
        $this->trackingUrls = $trackingUrls;
161
162
        return $this;
163
    }
164
165
    /**
166
     * @return array
167
     */
168
    public function getReceipt()
169
    {
170
        return $this->receipt;
171
    }
172
173
    /**
174
     * @param array $receipt
175
     *
176
     * @return Fulfillment
177
     */
178
    public function setReceipt($receipt)
179
    {
180
        $this->receipt = $receipt;
181
182
        return $this;
183
    }
184
185
    /**
186
     * @return string
187
     */
188
    public function getCreatedAt()
189
    {
190
        return $this->createdAt;
191
    }
192
193
    /**
194
     * @param string $createdAt
195
     *
196
     * @return Fulfillment
197
     */
198
    public function setCreatedAt($createdAt)
199
    {
200
        $this->createdAt = $createdAt;
201
202
        return $this;
203
    }
204
205
    /**
206
     * @return string
207
     */
208
    public function getUpdatedAt()
209
    {
210
        return $this->updatedAt;
211
    }
212
213
    /**
214
     * @param string $updatedAt
215
     *
216
     * @return Fulfillment
217
     */
218
    public function setUpdatedAt($updatedAt)
219
    {
220
        $this->updatedAt = $updatedAt;
221
222
        return $this;
223
    }
224
225
    /**
226
     * @return int
227
     */
228
    public function getOrderId()
229
    {
230
        return $this->orderId;
231
    }
232
233
    /**
234
     * @param int $orderId
235
     *
236
     * @return Fulfillment
237
     */
238
    public function setOrderId($orderId)
239
    {
240
        $this->orderId = $orderId;
241
242
        return $this;
243
    }
244
245
    /**
246
     * @return string
247
     */
248
    public function getStatus()
249
    {
250
        return $this->status;
251
    }
252
253
    /**
254
     * @param string $status
255
     *
256
     * @return Fulfillment
257
     */
258
    public function setStatus($status)
259
    {
260
        $this->status = $status;
261
262
        return $this;
263
    }
264
265
    /**
266
     * @return string
267
     */
268
    public function getTrackingCompany()
269
    {
270
        return $this->trackingCompany;
271
    }
272
273
    /**
274
     * @param string $trackingCompany
275
     *
276
     * @return Fulfillment
277
     */
278
    public function setTrackingCompany($trackingCompany)
279
    {
280
        $this->trackingCompany = $trackingCompany;
281
282
        return $this;
283
    }
284
285
    /**
286
     * @return string
287
     */
288
    public function getTrackingNumber()
289
    {
290
        return $this->trackingNumber;
291
    }
292
293
    /**
294
     * @param string $trackingNumber
295
     *
296
     * @return Fulfillment
297
     */
298
    public function setTrackingNumber($trackingNumber)
299
    {
300
        $this->trackingNumber = $trackingNumber;
301
302
        return $this;
303
    }
304
305
    /**
306
     * @return LineItem[]
307
     */
308
    public function getLineItems()
309
    {
310
        return $this->lineItems;
311
    }
312
313
    /**
314
     * @param LineItem[] $lineItems
315
     *
316
     * @return Fulfillment
317
     */
318
    public function setLineItems($lineItems)
319
    {
320
        $this->lineItems = $lineItems;
321
322
        return $this;
323
    }
324
325
    /**
326
     * @return array
327
     */
328
    public function getTrackingNumbers()
329
    {
330
        return $this->trackingNumbers;
331
    }
332
333
    /**
334
     * @param array $trackingNumbers
335
     * @return Fulfillment
336
     */
337
    public function setTrackingNumbers($trackingNumbers)
338
    {
339
        $this->trackingNumbers = $trackingNumbers;
340
341
        return $this;
342
    }
343
344
    /**
345
     * {@inheritdoc}
346
     */
347
    public static function getTypeCollection()
348
    {
349
        return array_merge(parent::getTypeCollection(), [
0 ignored issues
show
Best Practice introduced by
The expression return array_merge(paren...der\LineItem::class))); seems to be an array, but some of its elements' types (Slince\Shopify\Hydrator\Association\HasMany) are incompatible with the return type of the parent method Slince\Shopify\Common\Mo...odel::getTypeCollection of type Slince\Shopify\Hydrator\Type\DateTimeType[].

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
350
            new HasMany('lineItems', LineItem::class),
351
        ]);
352
    }
353
}