Passed
Push — master ( 4d4fc5...4bc7af )
by Amin
03:11
created

Representation::getHlsStreamInfo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * This file is part of the PHP-FFmpeg-video-streaming package.
5
 *
6
 * (c) Amin Yazdanpanah <[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 Streaming;
13
14
use Streaming\Exception\InvalidArgumentException;
15
16
class Representation
17
{
18
    private $kiloBitrate = 1000;
19
    private $audioKiloBitrate = null;
20
    private $resize = '';
21
    private $width = 0;
22
    private $height = 0;
23
    private $hls_stream_info = [];
24
25
    /**
26
     * @return mixed
27
     */
28
    public function getResize(): string
29
    {
30
        return $this->resize;
31
    }
32
33
    /**
34
     * @param $width
35
     * @param $height
36
     * @return Representation
37
     * @throws InvalidArgumentException
38
     */
39
    public function setResize(int $width, int $height): Representation
40
    {
41
        if ($width < 1 || $height < 1) {
42
            throw new InvalidArgumentException('Invalid resize value');
43
        }
44
45
        $this->width = $width;
46
        $this->height = $height;
47
        $this->resize = $width . "x" . $height;
48
49
        return $this;
50
    }
51
52
    /**
53
     * @return int
54
     */
55
    public function getKiloBitrate(): int
56
    {
57
        return $this->kiloBitrate;
58
    }
59
60
    /**
61
     * @return int|null
62
     */
63
    public function getAudioKiloBitrate()
64
    {
65
        return $this->audioKiloBitrate;
66
    }
67
68
    /**
69
     * Sets the video kiloBitrate value.
70
     *
71
     * @param  integer $kiloBitrate
72
     * @return Representation
73
     * @throws InvalidArgumentException
74
     */
75
    public function setKiloBitrate(int $kiloBitrate): Representation
76
    {
77
        if ($kiloBitrate < 1) {
78
            throw new InvalidArgumentException('Invalid kilo bit rate value');
79
        }
80
81
        $this->kiloBitrate = (int)$kiloBitrate;
82
        return $this;
83
    }
84
85
    /**
86
     * Sets the video kiloBitrate value.
87
     *
88
     * @param  integer $audioKiloBitrate
89
     * @return Representation
90
     * @throws InvalidArgumentException
91
     */
92
    public function setAudioKiloBitrate(int $audioKiloBitrate): Representation
93
    {
94
        $this->audioKiloBitrate = $audioKiloBitrate;
95
        return $this;
96
    }
97
98
    /**
99
     * @return int
100
     */
101
    public function getWidth(): int
102
    {
103
        return $this->width;
104
    }
105
106
    /**
107
     * @return int
108
     */
109
    public function getHeight(): int
110
    {
111
        return $this->height;
112
    }
113
114
    /**
115
     * @param array $hls_stream_info
116
     * @return Representation
117
     */
118
    public function setHlsStreamInfo(array $hls_stream_info): Representation
119
    {
120
        $this->hls_stream_info = $hls_stream_info;
121
        return $this;
122
    }
123
124
    /**
125
     * @return array
126
     */
127
    public function getHlsStreamInfo(): array
128
    {
129
        return $this->hls_stream_info;
130
    }
131
}