Completed
Push — master ( 0eb1a8...12216b )
by Amin
03:20
created

HLS::getTsSubDirectory()   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\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
    /** @var string */
35
    private $hls_base_url  = "";
36
37
    /**
38
     * @return string
39
     */
40
    public function getTsSubDirectory(): string
41
    {
42
        return $this->ts_sub_directory;
43
    }
44
45
    /**
46
     * @param string $ts_sub_directory
47
     * @return HLS
48
     */
49
    public function setTsSubDirectory(string $ts_sub_directory)
50
    {
51
        $this->ts_sub_directory = $ts_sub_directory;
52
        return $this;
53
    }
54
55
    /**
56
     * @param string $hls_time
57
     * @return HLS
58
     */
59
    public function setHlsTime(string $hls_time): HLS
60
    {
61
        $this->hls_time = $hls_time;
62
        return $this;
63
    }
64
65
    /**
66
     * @return string
67
     */
68
    public function getHlsTime(): string
69
    {
70
        return $this->hls_time;
71
    }
72
73
    /**
74
     * @param bool $hls_allow_cache
75
     * @return HLS
76
     */
77
    public function setHlsAllowCache(bool $hls_allow_cache): HLS
78
    {
79
        $this->hls_allow_cache = $hls_allow_cache;
80
        return $this;
81
    }
82
83
    /**
84
     * @return bool
85
     */
86
    public function isHlsAllowCache(): bool
87
    {
88
        return $this->hls_allow_cache;
89
    }
90
91
    /**
92
     * @param string $hls_key_info_file
93
     * @return HLS
94
     */
95
    public function setHlsKeyInfoFile(string $hls_key_info_file): HLS
96
    {
97
        $this->hls_key_info_file = $hls_key_info_file;
98
        return $this;
99
    }
100
101
    /**
102
     * @param string $url
103
     * @param string $path
104
     * @param string $binary
105
     * @return HLS
106
     * @throws Exception\InvalidArgumentException
107
     */
108
    public function generateRandomKeyInfo(string $url = null, string $path = null, string $binary = "openssl"): HLS
109
    {
110
        if (null === $url && null === $path) {
111
            $key_name = $url = Helper::randomString() . ".key";
112
            $path = $this->path_info["dirname"] . DIRECTORY_SEPARATOR . $key_name;
113
        }
114
115
        $this->setHlsKeyInfoFile(new KeyInfo($url, $path, $binary));
0 ignored issues
show
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

115
        $this->setHlsKeyInfoFile(new KeyInfo(/** @scrutinizer ignore-type */ $url, $path, $binary));
Loading history...
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

115
        $this->setHlsKeyInfoFile(new KeyInfo($url, /** @scrutinizer ignore-type */ $path, $binary));
Loading history...
116
        return $this;
117
    }
118
119
    /**
120
     * @return string
121
     */
122
    public function getHlsKeyInfoFile(): string
123
    {
124
        return $this->hls_key_info_file;
125
    }
126
127
    /**
128
     * @param string $hls_base_url
129
     * @return HLS
130
     */
131
    public function setHlsBaseUrl(string $hls_base_url): HLS
132
    {
133
        $this->hls_base_url = $hls_base_url;
134
        return $this;
135
    }
136
137
    /**
138
     * @return string
139
     */
140
    public function getHlsBaseUrl(): string
141
    {
142
        return $this->hls_base_url;
143
    }
144
145
    /**
146
     * @return Filter
147
     */
148
    protected function getFilter(): Filter
149
    {
150
        return $this->filter;
151
    }
152
153
    /**
154
     * @return mixed|void
155
     */
156
    protected function setFilter()
157
    {
158
        $this->filter = new HLSFilter($this);
159
    }
160
}
161