GifGenerator   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 25
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A generate() 0 23 1
1
<?php
2
3
namespace Jackal\Giffhanger\Generator;
4
5
use FFMpeg\Coordinate\Dimension;
6
use FFMpeg\Coordinate\TimeCode;
7
use FFMpeg\Media\Video;
8
use Jackal\Giffhanger\FFMpeg\ext\Media\Gif;
9
10
class GifGenerator extends VideoWebMGenerator
11
{
12
    public function generate() : void
13
    {
14
        $originalDestionation = $this->destination;
15
        $this->destination = $this->options->getTempFolder() . '/' . md5($this->sourceFile) . '-temp.avi';
16
17
        parent::generate();
18
19
        $this->addTempFileToRemove($this->destination);
20
21
        $ffmpeg = $this->getFFMpeg();
22
        /** @var Video $video */
23
        $video = $ffmpeg->open($this->destination);
24
25
        $gif = new Gif(
26
            $video,
27
            $video->getFFMpegDriver(),
28
            $video->getFFProbe(),
29
            TimeCode::fromSeconds(0),
30
            new Dimension($this->options->getDimensionWidth(), $this->options->getDimensionWidth() / $this->getRatio()),
0 ignored issues
show
Bug introduced by
$this->options->getDimen...h() / $this->getRatio() of type double is incompatible with the type integer expected by parameter $height of FFMpeg\Coordinate\Dimension::__construct(). ( Ignorable by Annotation )

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

30
            new Dimension($this->options->getDimensionWidth(), /** @scrutinizer ignore-type */ $this->options->getDimensionWidth() / $this->getRatio()),
Loading history...
31
            $this->getDuration()
32
        );
33
34
        $gif->save($originalDestionation);
35
    }
36
}
37