Passed
Push — master ( 9944a7...7eda7c )
by Amin
03:50 queued 13s
created

Media::isTmp()   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
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
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 mixed save(\FFMpeg\Format\FormatInterface $format, $outputPathfile)
18
 * @method mixed addFilter(\FFMpeg\Filters\FilterInterface $filter)
19
 */
20
class Media
21
{
22
23
    protected $media;
24
    /**
25
     * @var string
26
     */
27
    private $path;
28
    /**
29
     * @var bool
30
     */
31
    private $is_tmp;
32
33
    /**
34
     * Media constructor.
35
     * @param MediaTypeInterface $media
36
     * @param string $path
37
     * @param bool $is_tmp
38
     */
39
    public function __construct(MediaTypeInterface $media, string $path, bool $is_tmp)
40
    {
41
        $this->media = $media;
42
        $this->path = $path;
43
        $this->is_tmp = $is_tmp;
44
    }
45
46
    /**
47
     * @return DASH
48
     */
49
    public function DASH(): DASH
50
    {
51
        return new DASH($this);
52
    }
53
54
    /**
55
     * @return HLS
56
     */
57
    public function HLS(): HLS
58
    {
59
        return new HLS($this);
60
    }
61
62
63
    /**
64
     * @return array
65
     */
66
    public function probe(): array
67
    {
68
        return[
69
            'format' => $this->getFormat(),
0 ignored issues
show
Bug introduced by
The method getFormat() does not exist on Streaming\Media. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

69
            'format' => $this->/** @scrutinizer ignore-call */ getFormat(),
Loading history...
70
            'streams' => $this->getStreams()
0 ignored issues
show
Bug introduced by
The method getStreams() does not exist on Streaming\Media. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

70
            'streams' => $this->/** @scrutinizer ignore-call */ getStreams()
Loading history...
71
        ];
72
    }
73
74
    /**
75
     * @param $argument
76
     * @return Media
77
     */
78
    protected function isInstanceofArgument($argument)
79
    {
80
        return ($argument instanceof $this->media) ? $this : $argument;
81
    }
82
83
    /**
84
     * @param $method
85
     * @param $parameters
86
     * @return Media
87
     */
88
    public function __call($method, $parameters)
89
    {
90
        return $this->isInstanceofArgument(
91
            call_user_func_array([$this->media, $method], $parameters)
92
        );
93
    }
94
95
    /**
96
     * @return string
97
     */
98
    public function getPath(): string
99
    {
100
        return $this->path;
101
    }
102
103
    /**
104
     * @return bool
105
     */
106
    public function isTmp(): bool
107
    {
108
        return $this->is_tmp;
109
    }
110
}
111