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

Media::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
c 0
b 0
f 0
nc 1
nop 3
dl 0
loc 5
rs 10
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 FFMpeg\Media\MediaTypeInterface;
15
16
/**
17
 * @method \FFMpeg\Media\Video save(\FFMpeg\Format\FormatInterface $format, $outputPathfile)
18
 * @method \FFMpeg\Media\Video addFilter(\FFMpeg\Filters\FilterInterface $filter)
19
 * @method \FFMpeg\FFProbe\DataMapping\Format getFormat()
20
 * @method \FFMpeg\FFProbe\DataMapping\StreamCollection getStreams()
21
 */
22
class Media
23
{
24
25
    protected $media;
26
    /**
27
     * @var string
28
     */
29
    private $path;
30
    /**
31
     * @var bool
32
     */
33
    private $is_tmp;
34
35
    /**
36
     * Media constructor.
37
     * @param MediaTypeInterface $media
38
     * @param string $path
39
     * @param bool $is_tmp
40
     */
41
    public function __construct(MediaTypeInterface $media, string $path, bool $is_tmp)
42
    {
43
        $this->media = $media;
44
        $this->path = $path;
45
        $this->is_tmp = $is_tmp;
46
    }
47
48
    /**
49
     * @return DASH
50
     */
51
    public function DASH(): DASH
52
    {
53
        return new DASH($this);
54
    }
55
56
    /**
57
     * @return HLS
58
     */
59
    public function HLS(): HLS
60
    {
61
        return new HLS($this);
62
    }
63
64
    /**
65
     * @return StreamToFile
66
     */
67
    public function stream2file(): StreamToFile
68
    {
69
        return new StreamToFile($this);
70
    }
71
72
    /**
73
     * @param $argument
74
     * @return Media
75
     */
76
    private function isInstanceofArgument($argument)
77
    {
78
        return ($argument instanceof $this->media) ? $this : $argument;
79
    }
80
81
    /**
82
     * @param $method
83
     * @param $parameters
84
     * @return Media
85
     */
86
    public function __call($method, $parameters)
87
    {
88
        return $this->isInstanceofArgument(
89
            call_user_func_array([$this->media, $method], $parameters)
90
        );
91
    }
92
93
    /**
94
     * @return string
95
     */
96
    public function getPath(): string
97
    {
98
        return $this->path;
99
    }
100
101
    /**
102
     * @return bool
103
     */
104
    public function isTmp(): bool
105
    {
106
        return $this->is_tmp;
107
    }
108
}