Passed
Push — master ( e02544...974e99 )
by Omid
01:20 queued 11s
created

VideosRequestParameters::getChannelId()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
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 int                     getOffset()
14
 * @method VideosRequestParameters setOffset(int $offset)
15
 * @method int                     getLimit()
16
 * @method VideosRequestParameters setLimit(int $limit)
17
 * @method string                  getOrder()
18
 * @method string                  getOrderProperty()
19
 * @method VideosRequestParameters setOrderProperty(string $orderProperty)
20
 * @method string                  getSearchTerm()
21
 * @method VideosRequestParameters setSearchTerm(string $searchTerm)
22
 * @method bool                    isIncludeCustomMetadata()
23
 * @method VideosRequestParameters setIncludeCustomMetadata(bool $includeCustomMetadata)
24
 * @method string                  getCustomMetadataField()
25
 * @method VideosRequestParameters setCustomMetadataField(int $customMetadataField)
26
 * @method string                  getSearchInField()
27
 * @method VideosRequestParameters setSearchInField(string $searchInField)
28
 * @method string                  getPublicationState()
29
 * @method bool                    isIncludeKeywords()
30
 * @method VideosRequestParameters setIncludeKeywords(bool $includeKeywords)
31
 * @method VideosRequestParameters setIncludeChannelAssignments(bool $includeChannels)
32
 * @method bool                    isIncludeSubChannels()
33
 * @method VideosRequestParameters setIncludeSubChannels(bool $includeSubChannels)
34
 * @method VideosRequestParameters setMetadataSetKey(string $metadataSetKey)
35
 * @method string                  getMetadataSetKey()
36
 */
37
class VideosRequestParameters
38
{
39
    use AccessorTrait;
40
41
    public function setOrder(string $order): self
42
    {
43
        $pool = ['asc', 'desc'];
44
45
        // Silently ignore wrong values
46
        if (in_array($order, $pool)) {
47
            $this->container['order'] = $order;
48
        }
49
50
        return $this;
51
    }
52
53
    public function setPublicationState(string $publicationState): self
54
    {
55
        if (in_array($publicationState, PublicationState::getValues())) {
56
            $this->container['publication_state'] = $publicationState;
57
        }
58
59
        return $this;
60
    }
61
62
    public function getChannelIds(): array
63
    {
64
        return $this->container['channel_id'] ?? [];
65
    }
66
67
    public function getChannelId(): ?int
68
    {
69
        if (isset($this->container['channel_id'])) {
70
            return $this->container['channel_id'][0];
71
        }
72
73
        return null;
74
    }
75
76
    public function setChannelIds(array $channelIds): self
77
    {
78
        $this->container['channel_id'] = $channelIds;
79
80
        return $this;
81
    }
82
83
    public function setChannelId(int $channelId): self
84
    {
85
        return $this->setChannelIds([$channelId]);
86
    }
87
}
88