Completed
Push — master ( 94616b...d1942c )
by Sébastien
03:09
created

DetectionService   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
eloc 8
dl 0
loc 32
c 0
b 0
f 0
ccs 0
cts 12
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getInterlaceDetect() 0 2 1
A detectInterlacement() 0 5 1
A __construct() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Soluble\MediaTools\Video;
6
7
use Soluble\MediaTools\Config\FFMpegConfig;
8
use Soluble\MediaTools\Config\FFProbeConfig;
9
use Soluble\MediaTools\Exception\FileNotFoundException;
10
use Soluble\MediaTools\Video\Detection\InterlaceDetect;
11
use Soluble\MediaTools\Video\Detection\InterlaceGuess;
12
use Symfony\Component\Process\Exception\RuntimeException as SPRuntimeException;
13
14
class DetectionService implements DetectionServiceInterface
15
{
16
    /** @var FFProbeConfig */
17
    protected $ffprobeConfig;
18
19
    /** @var FFMpegConfig */
20
    protected $ffmpegConfig;
21
22
    /** @var array */
23
    protected $interlaceDetectCache;
24
25
    public function __construct(FFProbeConfig $ffProbeConfig, FFMpegConfig $ffmpegConfig)
26
    {
27
        $this->ffprobeConfig = $ffProbeConfig;
28
        $this->ffmpegConfig  = $ffmpegConfig;
29
    }
30
31
    public function getInterlaceDetect(): InterlaceDetect
32
    {
33
    }
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return Soluble\MediaTools\Video\Detection\InterlaceDetect. Consider adding a return statement or allowing null as return value.

For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example:

interface ReturnsInt {
    public function returnsIntHinted(): int;
}

class MyClass implements ReturnsInt {
    public function returnsIntHinted(): int
    {
        if (foo()) {
            return 123;
        }
        // here: null is implicitly returned
    }
}
Loading history...
34
35
    /**
36
     * @param int $maxFramesToAnalyze interlacement detection can be heavy, limit the number of frames to analyze
37
     *
38
     * @throws SPRuntimeException
39
     * @throws FileNotFoundException
40
     */
41
    public function detectInterlacement(string $file, int $maxFramesToAnalyze = 1000): InterlaceGuess
42
    {
43
        $interlaceDetect = new InterlaceDetect($this->ffmpegConfig);
44
45
        return $interlaceDetect->guessInterlacing($file, $maxFramesToAnalyze);
46
    }
47
}
48