Failed Conditions
Push — master ( 5e65a4...91e9bd )
by Sébastien
03:12
created

src/Video/DetectionService.php (2 issues)

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 DetectionService implements DetectionServiceInterface
20
{
21 2
    /** @var FFMpegConfigInterface */
22
    protected $ffmpegConfig;
23 2
24 2
    /** @var LoggerInterface|NullLogger */
25
    protected $logger;
26
27
    public function __construct(FFMpegConfigInterface $ffmpegConfig, ?LoggerInterface $logger = null)
28
    {
29
        $this->ffmpegConfig  = $ffmpegConfig;
0 ignored issues
show
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
        $this->logger        = $logger ?? new NullLogger();
0 ignored issues
show
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
    }
32
33
    /**
34
     * @param int $maxFramesToAnalyze interlacement detection can be heavy, limit the number of frames to analyze
35 2
     *
36
     * @throws DetectionExceptionInterface
37 2
     * @throws DetectionProcessExceptionInterface
38
     * @throws ProcessFailedException
39 2
     * @throws MissingInputFileException
40
     * @throws RuntimeException
41
     */
42
    public function detectInterlacement(string $file, int $maxFramesToAnalyze = InterlaceDetect::DEFAULT_INTERLACE_MAX_FRAMES, ?ProcessParamsInterface $processParams = null): InterlaceDetectGuess
43
    {
44
        $interlaceDetect = new InterlaceDetect($this->ffmpegConfig);
45
46
        return $interlaceDetect->guessInterlacing($file, $maxFramesToAnalyze, $processParams);
47
    }
48
}
49