Completed
Pull Request — master (#18)
by Ruben
04:55
created

Video::getViews()   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
namespace MovingImage\Client\VMPro\Entity;
4
5
use JMS\Serializer\Annotation\Type;
6
use JMS\Serializer\Annotation\SerializedName;
7
use MovingImage\Meta\Interfaces\VideoInterface;
8
9
/**
10
 * Class Video.
11
 *
12
 * @author Omid Rad <[email protected]>
13
 */
14
class Video implements VideoInterface
15
{
16
    /**
17
     * @Type("string")
18
     */
19
    private $id;
20
21
    /**
22
     * @Type("string")
23
     */
24
    private $title;
25
26
    /**
27
     * @Type("string")
28
     */
29
    private $description;
30
31
    /**
32
     * @Type("string")
33
     */
34
    private $thumbnail;
35
36
    /**
37
     * @Type("integer")
38
     */
39
    private $length;
40
41
    /**
42
     * @Type("integer")
43
     * @SerializedName("createdDate")
44
     */
45
    private $createdDate;
46
47
    /**
48
     * @Type("integer")
49
     * @SerializedName("modifiedDate")
50
     */
51
    private $modifiedDate;
52
53
    /**
54
     * @Type("integer")
55
     * @SerializedName("uploadDate")
56
     */
57
    private $uploadDate;
58
59
    /**
60
     * @Type("integer")
61
     */
62
    private $generation;
63
64
    /**
65
     * @Type("integer")
66
     */
67
    private $plays;
68
69
    /**
70
     * @Type("integer")
71
     */
72
    private $views;
73
74
    /**
75
     * @Type("boolean")
76
     * @SerializedName("allFormatsAvailable")
77
     */
78
    private $allFormatsAvailable;
79
80
    /**
81
     * @TODO replace it with array collection
82
     *
83
     * @Type("array")
84
     * @SerializedName("customMetadata")
85
     */
86
    private $customMetadata;
87
88
    /**
89
     * @TODO replace it with array collection
90
     *
91
     * @Type("array")
92
     */
93
    private $keywords;
94
95
    /**
96
     * @TODO replace it with array collection
97
     *
98
     * @Type("array")
99
     */
100
    private $stills;
101
102
    /**
103
     * @Type("boolean")
104
     */
105
    private $published;
106
107
    /**
108
     * @param string $id
109
     *
110
     * @return Video
111
     */
112
    public function setId($id)
113
    {
114
        $this->id = $id;
115
116
        return $this;
117
    }
118
119
    /**
120
     * @return string
121
     */
122
    public function getId()
123
    {
124
        return $this->id;
125
    }
126
127
    /**
128
     * @return string
129
     */
130
    public function getTitle()
131
    {
132
        return $this->title;
133
    }
134
135
    /**
136
     * @param string $title
137
     *
138
     * @return Video
139
     */
140
    public function setTitle($title)
141
    {
142
        $this->title = $title;
143
144
        return $this;
145
    }
146
147
    /**
148
     * @return string
149
     */
150
    public function getDescription()
151
    {
152
        return $this->description;
153
    }
154
155
    /**
156
     * @param string $description
157
     *
158
     * @return Video
159
     */
160
    public function setDescription($description)
161
    {
162
        $this->description = $description;
163
164
        return $this;
165
    }
166
167
    /**
168
     * @return string
169
     */
170
    public function getThumbnail()
171
    {
172
        return $this->thumbnail;
173
    }
174
175
    /**
176
     * @param string $thumbnail
177
     *
178
     * @return Video
179
     */
180
    public function setThumbnail($thumbnail)
181
    {
182
        $this->thumbnail = $thumbnail;
183
184
        return $this;
185
    }
186
187
    /**
188
     * @return int
189
     */
190
    public function getLength()
191
    {
192
        return $this->length;
193
    }
194
195
    /**
196
     * @param int $length
197
     *
198
     * @return Video
199
     */
200
    public function setLength($length)
201
    {
202
        $this->length = $length;
203
204
        return $this;
205
    }
206
207
    /**
208
     * @return int
209
     */
210
    public function getCreatedDate()
211
    {
212
        return $this->createdDate;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return $this->createdDate; (integer) is incompatible with the return type declared by the interface MovingImage\Meta\Interfa...terface::getCreatedDate of type DateTime.

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 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('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...
213
    }
214
215
    /**
216
     * @param int $createdDate
217
     *
218
     * @return Video
219
     */
220
    public function setCreatedDate($createdDate)
221
    {
222
        $this->createdDate = $createdDate;
223
224
        return $this;
225
    }
226
227
    /**
228
     * @return int
229
     */
230
    public function getModifiedDate()
231
    {
232
        return $this->modifiedDate;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return $this->modifiedDate; (integer) is incompatible with the return type declared by the interface MovingImage\Meta\Interfa...erface::getModifiedDate of type DateTime.

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 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('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...
233
    }
234
235
    /**
236
     * @param int $modifiedDate
237
     *
238
     * @return Video
239
     */
240
    public function setModifiedDate($modifiedDate)
241
    {
242
        $this->modifiedDate = $modifiedDate;
243
244
        return $this;
245
    }
246
247
    /**
248
     * @return int
249
     */
250
    public function getUploadDate()
251
    {
252
        return $this->uploadDate;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return $this->uploadDate; (integer) is incompatible with the return type declared by the interface MovingImage\Meta\Interfa...nterface::getUploadDate of type DateTime.

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 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('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...
253
    }
254
255
    /**
256
     * @param int $uploadDate
257
     *
258
     * @return Video
259
     */
260
    public function setUploadDate($uploadDate)
261
    {
262
        $this->uploadDate = $uploadDate;
263
264
        return $this;
265
    }
266
267
    /**
268
     * @return int
269
     */
270
    public function getGeneration()
271
    {
272
        return $this->generation;
273
    }
274
275
    /**
276
     * @param int $generation
277
     *
278
     * @return Video
279
     */
280
    public function setGeneration($generation)
281
    {
282
        $this->generation = $generation;
283
284
        return $this;
285
    }
286
287
    /**
288
     * @return int
289
     */
290
    public function getPlays()
291
    {
292
        return $this->plays;
293
    }
294
295
    /**
296
     * @param int $plays
297
     *
298
     * @return Video
299
     */
300
    public function setPlays($plays)
301
    {
302
        $this->plays = $plays;
303
304
        return $this;
305
    }
306
307
    /**
308
     * @return int
309
     */
310
    public function getViews()
311
    {
312
        return $this->views;
313
    }
314
315
    /**
316
     * @param int $views
317
     *
318
     * @return Video
319
     */
320
    public function setViews($views)
321
    {
322
        $this->views = $views;
323
324
        return $this;
325
    }
326
327
    /**
328
     * @return bool
329
     */
330
    public function getAllFormatsAvailable()
331
    {
332
        return $this->allFormatsAvailable;
333
    }
334
335
    /**
336
     * @param bool $allFormatsAvailable
337
     *
338
     * @return Video
339
     */
340
    public function setAllFormatsAvailable($allFormatsAvailable)
341
    {
342
        $this->allFormatsAvailable = $allFormatsAvailable;
343
344
        return $this;
345
    }
346
347
    /**
348
     * @return array
349
     */
350
    public function getCustomMetadata()
351
    {
352
        return $this->customMetadata;
353
    }
354
355
    /**
356
     * @param array $customMetadata
357
     *
358
     * @return Video
359
     */
360
    public function setCustomMetadata($customMetadata)
361
    {
362
        $this->customMetadata = $customMetadata;
363
364
        return $this;
365
    }
366
367
    /**
368
     * @return array
369
     */
370
    public function getKeywords()
371
    {
372
        return $this->keywords;
373
    }
374
375
    /**
376
     * @param array $keywords
377
     *
378
     * @return Video
379
     */
380
    public function setKeywords($keywords)
381
    {
382
        $this->keywords = $keywords;
383
384
        return $this;
385
    }
386
387
    /**
388
     * @return array
389
     */
390
    public function getStills()
391
    {
392
        return $this->stills;
393
    }
394
395
    /**
396
     * @param array $stills
397
     *
398
     * @return Video
399
     */
400
    public function setStills($stills)
401
    {
402
        $this->stills = $stills;
403
404
        return $this;
405
    }
406
407
    /**
408
     * @return mixed
409
     */
410
    public function getPublished()
411
    {
412
        return $this->published;
413
    }
414
415
    /**
416
     * @param mixed $published
417
     *
418
     * @return Video
419
     */
420
    public function setPublished($published)
421
    {
422
        $this->published = $published;
423
424
        return $this;
425
    }
426
427
    /**
428
     * {@inheritdoc}
429
     */
430
    public function isPublished()
431
    {
432
        return $this->getPublished();
433
    }
434
435
    /**
436
     * {@inheritdoc}
437
     */
438
    public function getStatus()
439
    {
440
        return $this->isPublished()
441
            ? VideoInterface::STATUS_PUBLISHED
442
            : VideoInterface::STATUS_NOT_PUBLISHED;
443
    }
444
}
445