Completed
Pull Request — master (#86)
by
unknown
01:30
created

FrameExporter   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 37
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A accurate() 0 6 1
A unaccurate() 0 6 1
A getAccuracy() 0 4 1
A getBase64() 0 4 1
A saveFrame() 0 6 1
1
<?php
2
3
namespace Pbmedia\LaravelFFMpeg;
4
5
class FrameExporter extends MediaExporter
6
{
7
    protected $mustBeAccurate = false;
8
9
    protected $saveMethod = 'saveFrame';
10
11
    public function accurate(): MediaExporter
12
    {
13
        $this->mustBeAccurate = true;
14
15
        return $this;
16
    }
17
18
    public function unaccurate(): MediaExporter
19
    {
20
        $this->mustBeAccurate = false;
21
22
        return $this;
23
    }
24
25
    public function getAccuracy(): bool
26
    {
27
        return $this->mustBeAccurate;
28
    }
29
    
30
    public function getBase64(string $fullPath): string
31
    {
32
        return $this->media->save($fullPath, $this->getAccuracy(), true);
0 ignored issues
show
Documentation introduced by
$fullPath is of type string, but the function expects a object<FFMpeg\Format\FormatInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Unused Code introduced by
The call to Media::save() has too many arguments starting with true.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
33
    }
34
35
    public function saveFrame(string $fullPath): MediaExporter
36
    {
37
        $this->media->save($fullPath, $this->getAccuracy());
0 ignored issues
show
Documentation introduced by
$fullPath is of type string, but the function expects a object<FFMpeg\Format\FormatInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
38
39
        return $this;
40
    }
41
}
42