Passed
Push — master ( 67f2c8...68e9c9 )
by Amin
01:53
created

Media::__construct()   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 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Copyright 2019 Amin Yazdanpanah<http://www.aminyazdanpanah.com>.
5
 *
6
 * Licensed under the MIT License;
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 *      https://opensource.org/licenses/MIT
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
namespace AYazdanpanah\FFMpegStreaming;
20
21
use FFMpeg\FFProbe\DataMapping\Stream;
22
use FFMpeg\Media\MediaTypeInterface;
23
24
/**
25
 * @method mixed save(\FFMpeg\Format\FormatInterface $format, $outputPathfile)
26
 * @method mixed addFilter(\FFMpeg\Filters\FilterInterface $filter)
27
 * @method mixed getStreams()
28
 */
29
class Media
30
{
31
32
    protected $media;
33
    /**
34
     * @var string
35
     */
36
    private $path;
37
38
    /**
39
     * Media constructor.
40
     * @param MediaTypeInterface $media
41
     * @param string $path
42
     */
43
    public function __construct(MediaTypeInterface $media, string $path)
44
    {
45
        $this->media = $media;
46
        $this->path = $path;
47
    }
48
49
    /**
50
     * @return DASH
51
     */
52
    public function DASH(): DASH
53
    {
54
        return new DASH($this);
55
    }
56
57
    /**
58
     * @return Live
59
     */
60
    public function live(): Live
0 ignored issues
show
Bug introduced by
The type AYazdanpanah\FFMpegStreaming\Live was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
61
    {
62
        return new Live($this);
63
    }
64
65
    /**
66
     * @return HLS
67
     */
68
    public function HLS(): HLS
69
    {
70
        return new HLS($this);
71
    }
72
73
    /**
74
     * @param $argument
75
     * @return Media
76
     */
77
    protected function isInstanceofArgument($argument)
78
    {
79
        return ($argument instanceof $this->media) ? $this : $argument;
80
    }
81
82
    /**
83
     * @param $method
84
     * @param $parameters
85
     * @return Media
86
     */
87
    public function __call($method, $parameters)
88
    {
89
        return $this->isInstanceofArgument(
90
            call_user_func_array([$this->media, $method], $parameters)
91
        );
92
    }
93
94
    /**
95
     * @return mixed
96
     */
97
    public function getFirstStream(): Stream
98
    {
99
        return $this->media->getStreams()->first();
0 ignored issues
show
Bug introduced by
The method getStreams() does not exist on FFMpeg\Media\MediaTypeInterface. It seems like you code against a sub-type of FFMpeg\Media\MediaTypeInterface such as FFMpeg\Media\AbstractStreamableMedia. ( Ignorable by Annotation )

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

99
        return $this->media->/** @scrutinizer ignore-call */ getStreams()->first();
Loading history...
100
    }
101
102
    /**
103
     * @return array
104
     */
105
    public function getPathInfo(): array
106
    {
107
        return pathinfo($this->path);
108
    }
109
}
110