Completed
Push — master ( 8c2386...3648da )
by Amin
03:00
created

HLS::setTsSubDirectory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
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\Filters\HLSFilter;
15
use Streaming\Traits\Representation as Representations;
16
use Streaming\Filters\Filter;
17
18
class HLS extends Export
19
{
20
    use Representations;
21
22
    /** @var string */
23
    private $hls_time = 10;
24
25
    /** @var bool */
26
    private $hls_allow_cache = true;
27
28
    /** @var string */
29
    private $hls_key_info_file = "";
30
31
    /** @var string */
32
    private $ts_sub_directory = "";
33
34
    /**
35
     * @return string
36
     */
37
    public function getTsSubDirectory(): string
38
    {
39
        return $this->ts_sub_directory;
40
    }
41
42
    /**
43
     * @param string $ts_sub_directory
44
     * @return HLS
45
     */
46
    public function setTsSubDirectory(string $ts_sub_directory)
47
    {
48
        $this->ts_sub_directory = $ts_sub_directory;
49
        return $this;
50
    }
51
52
    /**
53
     * @param string $hls_time
54
     * @return HLS
55
     */
56
    public function setHlsTime(string $hls_time): HLS
57
    {
58
        $this->hls_time = $hls_time;
59
        return $this;
60
    }
61
62
    /**
63
     * @return string
64
     */
65
    public function getHlsTime(): string
66
    {
67
        return $this->hls_time;
68
    }
69
70
    /**
71
     * @param bool $hls_allow_cache
72
     * @return HLS
73
     */
74
    public function setHlsAllowCache(bool $hls_allow_cache): HLS
75
    {
76
        $this->hls_allow_cache = $hls_allow_cache;
77
        return $this;
78
    }
79
80
    /**
81
     * @return bool
82
     */
83
    public function isHlsAllowCache(): bool
84
    {
85
        return $this->hls_allow_cache;
86
    }
87
88
    /**
89
     * @param string $hls_key_info_file
90
     * @return HLS
91
     */
92
    public function setHlsKeyInfoFile(string $hls_key_info_file): HLS
93
    {
94
        $this->hls_key_info_file = $hls_key_info_file;
95
        return $this;
96
    }
97
98
    /**
99
     * @param string $url
100
     * @param string $path
101
     * @param string $binary
102
     * @return HLS
103
     * @throws Exception\Exception
104
     */
105
    public function generateRandomKeyInfo(string $url = null, string $path = null, string $binary = "openssl"): HLS
106
    {
107
        if (null === $url && null === $path) {
108
            $key_name = $url = Helper::randomString() . ".key";
109
            $path = $this->path_info["dirname"] . DIRECTORY_SEPARATOR . $key_name;
110
        }
111
112
        $this->setHlsKeyInfoFile(new KeyInfo($url, $path, $binary));
0 ignored issues
show
Bug introduced by
It seems like $path can also be of type null; however, parameter $path of Streaming\KeyInfo::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

112
        $this->setHlsKeyInfoFile(new KeyInfo($url, /** @scrutinizer ignore-type */ $path, $binary));
Loading history...
Bug introduced by
It seems like $url can also be of type null; however, parameter $url of Streaming\KeyInfo::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

112
        $this->setHlsKeyInfoFile(new KeyInfo(/** @scrutinizer ignore-type */ $url, $path, $binary));
Loading history...
113
        return $this;
114
    }
115
116
    /**
117
     * @return string
118
     */
119
    public function getHlsKeyInfoFile(): string
120
    {
121
        return $this->hls_key_info_file;
122
    }
123
124
    /**
125
     * @return Filter
126
     */
127
    protected function getFilter(): Filter
128
    {
129
        return $this->filter;
130
    }
131
132
    /**
133
     * @return mixed|void
134
     */
135
    protected function setFilter()
136
    {
137
        $this->filter = new HLSFilter($this);
138
    }
139
}
140