Passed
Push — master ( 55b9e7...e379f9 )
by Sébastien
02:48 queued 11s
created

GoogleVod2019Preset::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Soluble\MediaTools\Preset\WebM;
6
7
use Soluble\MediaTools\Preset\PresetInterface;
8
use Soluble\MediaTools\Video\VideoAnalyzerInterface;
9
use Soluble\MediaTools\Video\VideoConverterInterface;
10
use Soluble\MediaTools\Video\VideoConvertParams;
11
use Soluble\MediaTools\Video\VideoInfoReaderInterface;
12
13
class GoogleVod2019Preset implements PresetInterface
14
{
15
    /** @var VideoInfoReaderInterface */
16
    private $reader;
17
18
    /** @var VideoConverterInterface */
19
    private $converter;
20
21
    /** @var VideoAnalyzerInterface */
22
    private $analyzer;
23
24
    public function __construct(VideoInfoReaderInterface $reader, VideoConverterInterface $converter, VideoAnalyzerInterface $analyzer)
25
    {
26
        $this->converter = $converter;
27
        $this->reader    = $reader;
28
        $this->analyzer  = $analyzer;
29
    }
30
31
    public function getName(): string
32
    {
33
        return __CLASS__;
34
    }
35
36
    public function convert(string $file, ?int $width = null, ?int $height = null): void
37
    {
38
        $info = $this->reader->getInfo($file);
39
40
        $vStream = $info->getVideoStreams()->getFirst();
41
        $aStream = $info->getAudioStreams()->getFirst();
0 ignored issues
show
Unused Code introduced by
The assignment to $aStream is dead and can be removed.
Loading history...
42
43
        $width  = $width ?? $vStream->getWidth();
44
        $height = $height ?? $vStream->getHeight();
45
46
        $params = $this->getParams($width, $height);
0 ignored issues
show
Unused Code introduced by
The assignment to $params is dead and can be removed.
Loading history...
47
    }
48
49
    public function getParams(int $width, int $height): VideoConvertParams
0 ignored issues
show
Unused Code introduced by
The parameter $width is not used and could be removed. ( Ignorable by Annotation )

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

49
    public function getParams(/** @scrutinizer ignore-unused */ int $width, int $height): VideoConvertParams

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $height is not used and could be removed. ( Ignorable by Annotation )

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

49
    public function getParams(int $width, /** @scrutinizer ignore-unused */ int $height): VideoConvertParams

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
50
    {
51
        $params = (new VideoConvertParams())
52
            ->withVideoCodec('vp9');
53
54
        return $params;
55
    }
56
}
57