Passed
Push — master ( 3ee3fe...b14545 )
by Amin
04:48
created

Representation::setKiloBitrate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 9
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
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\Exception;
15
16
class Representation
17
{
18
    private $kiloBitrate = 1000;
19
    private $resize = '';
20
    private $width = 0;
21
    private $height = 0;
22
23
    /**
24
     * @return mixed
25
     */
26
    public function getResize()
27
    {
28
        return $this->resize;
29
    }
30
31
    /**
32
     * @param $width
33
     * @param $height
34
     * @return Representation
35
     * @throws Exception
36
     */
37
    public function setResize(int $width, int $height): Representation
38
    {
39
        if ($width < 1 || $height < 1) {
40
            throw new Exception('Wrong resize value');
41
        }
42
43
        $this->width = $width;
44
        $this->height = $height;
45
        $this->resize = $width . "x" . $height;
46
47
        return $this;
48
    }
49
50
    /**
51
     * @return int
52
     */
53
    public function getKiloBitrate()
54
    {
55
        return $this->kiloBitrate;
56
    }
57
58
    /**
59
     * Sets the kiloBitrate value.
60
     *
61
     * @param  integer $kiloBitrate
62
     * @return Representation
63
     * @throws Exception
64
     */
65
    public function setKiloBitrate($kiloBitrate)
66
    {
67
        if ($kiloBitrate < 1) {
68
            throw new Exception('Wrong kilo bit rate value');
69
        }
70
71
        $this->kiloBitrate = (int)$kiloBitrate;
72
73
        return $this;
74
    }
75
76
    /**
77
     * @return int
78
     */
79
    public function getWidth(): int
80
    {
81
        return $this->width;
82
    }
83
84
    /**
85
     * @return int
86
     */
87
    public function getHeight(): int
88
    {
89
        return $this->height;
90
    }
91
}