Passed
Push — master ( 89fbe5...c257f0 )
by Sébastien
02:18
created

VideoAnalyzer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 28
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A detectInterlacement() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Soluble\MediaTools\Video;
6
7
use Psr\Log\LoggerInterface;
8
use Psr\Log\NullLogger;
9
use Soluble\MediaTools\Common\Process\ProcessParamsInterface;
10
use Soluble\MediaTools\Video\Config\FFMpegConfigInterface;
11
use Soluble\MediaTools\Video\Detection\InterlaceDetect;
12
use Soluble\MediaTools\Video\Detection\InterlaceDetectGuess;
13
use Soluble\MediaTools\Video\Exception\DetectionExceptionInterface;
14
use Soluble\MediaTools\Video\Exception\DetectionProcessExceptionInterface;
15
use Soluble\MediaTools\Video\Exception\MissingInputFileException;
16
use Soluble\MediaTools\Video\Exception\ProcessFailedException;
17
use Soluble\MediaTools\Video\Exception\RuntimeException;
18
19
class VideoAnalyzer implements VideoAnalyzerInterface
20
{
21
    /** @var FFMpegConfigInterface */
22
    protected $ffmpegConfig;
23
24
    /** @var LoggerInterface|NullLogger */
25
    protected $logger;
26
27 2
    public function __construct(FFMpegConfigInterface $ffmpegConfig, ?LoggerInterface $logger = null)
28
    {
29 2
        $this->ffmpegConfig  = $ffmpegConfig;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 1 space but found 2 spaces

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
30 2
        $this->logger        = $logger ?? new NullLogger();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 7 spaces but found 8 spaces

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
31 2
    }
32
33
    /**
34
     * @param int $maxFramesToAnalyze interlacement detection can be heavy, limit the number of frames to analyze
35
     *
36
     * @throws DetectionExceptionInterface
37
     * @throws DetectionProcessExceptionInterface
38
     * @throws ProcessFailedException
39
     * @throws MissingInputFileException
40
     * @throws RuntimeException
41
     */
42 2
    public function detectInterlacement(string $file, int $maxFramesToAnalyze = InterlaceDetect::DEFAULT_INTERLACE_MAX_FRAMES, ?ProcessParamsInterface $processParams = null): InterlaceDetectGuess
43
    {
44 2
        $interlaceDetect = new InterlaceDetect($this->ffmpegConfig);
45
46 2
        return $interlaceDetect->guessInterlacing($file, $maxFramesToAnalyze, $processParams);
47
    }
48
}
49