1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace MovingImage\Client\VMPro\Entity; |
6
|
|
|
|
7
|
|
|
use MovingImage\Client\VMPro\Util\AccessorTrait; |
8
|
|
|
use MovingImage\Meta\Enums\PublicationState; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* @method int getVideoId() |
12
|
|
|
* @method VideosRequestParameters setVideoId(int $videoId) |
13
|
|
|
* @method string getChannelId() returns a comma separated string for all channels, eg. 34534,333,42 |
14
|
|
|
* @method int getOffset() |
15
|
|
|
* @method VideosRequestParameters setOffset(int $offset) |
16
|
|
|
* @method int getLimit() |
17
|
|
|
* @method VideosRequestParameters setLimit(int $limit) |
18
|
|
|
* @method string getOrder() |
19
|
|
|
* @method string getOrderProperty() |
20
|
|
|
* @method VideosRequestParameters setOrderProperty(string $orderProperty) |
21
|
|
|
* @method string getSearchTerm() |
22
|
|
|
* @method VideosRequestParameters setSearchTerm(string $searchTerm) |
23
|
|
|
* @method bool isIncludeCustomMetadata() |
24
|
|
|
* @method VideosRequestParameters setIncludeCustomMetadata(bool $includeCustomMetadata) |
25
|
|
|
* @method string getCustomMetadataField() |
26
|
|
|
* @method VideosRequestParameters setCustomMetadataField(int $customMetadataField) |
27
|
|
|
* @method string getSearchInField() |
28
|
|
|
* @method VideosRequestParameters setSearchInField(string $searchInField) |
29
|
|
|
* @method string getPublicationState() |
30
|
|
|
* @method bool isIncludeKeywords() |
31
|
|
|
* @method VideosRequestParameters setIncludeKeywords(bool $includeKeywords) |
32
|
|
|
* @method VideosRequestParameters setIncludeChannelAssignments(bool $includeChannels) |
33
|
|
|
* @method bool isIncludeSubChannels() |
34
|
|
|
* @method VideosRequestParameters setIncludeSubChannels(bool $includeSubChannels) |
35
|
|
|
* @method VideosRequestParameters setMetadataSetKey(string $metadataSetKey) |
36
|
|
|
* @method string getMetadataSetKey() |
37
|
|
|
*/ |
38
|
|
|
class VideosRequestParameters |
39
|
|
|
{ |
40
|
|
|
use AccessorTrait; |
41
|
|
|
|
42
|
|
View Code Duplication |
public function setOrder(string $order): self |
|
|
|
|
43
|
|
|
{ |
44
|
|
|
$pool = ['asc', 'desc']; |
45
|
|
|
|
46
|
|
|
// Silently ignore wrong values |
47
|
|
|
if (in_array($order, $pool)) { |
48
|
|
|
$this->container['order'] = $order; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
return $this; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function setPublicationState(string $publicationState): self |
55
|
|
|
{ |
56
|
|
|
if (in_array($publicationState, PublicationState::getValues())) { |
57
|
|
|
$this->container['publication_state'] = $publicationState; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
return $this; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function getChannelIds(): array |
64
|
|
|
{ |
65
|
|
|
return explode(',', $this->container['channel_id']); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function setChannelIds(array $channelIds): self |
69
|
|
|
{ |
70
|
|
|
$this->container['channel_id'] = implode(',', $channelIds); |
71
|
|
|
|
72
|
|
|
return $this; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function setChannelId(int $channelId): self |
76
|
|
|
{ |
77
|
|
|
return $this->setChannelIds([$channelId]); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.