Passed
Branch master (267be1)
by Eugene
03:10
created

FindResourceLastVersionCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 38
ccs 19
cts 19
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A __invoke() 0 20 3
1
<?php
2
namespace Staticus\Resources\Commands;
3
4
use League\Flysystem\FilesystemInterface;
5
use Staticus\Resources\ResourceDOInterface;
6
7
class FindResourceLastVersionCommand implements ResourceCommandInterface
8
{
9
    /**
10
     * @var ResourceDOInterface
11
     */
12
    protected $resourceDO;
13
    /**
14
     * @var FilesystemInterface
15
     */
16
    protected $filesystem;
17
18 10
    public function __construct(ResourceDOInterface $resourceDO, FilesystemInterface $filesystem)
19
    {
20 10
        $this->resourceDO = $resourceDO;
21 10
        $this->filesystem = $filesystem;
22 10
    }
23
24 10
    public function __invoke()
25
    {
26 10
        $command = new FindResourceOptionsCommand($this->resourceDO, $this->filesystem);
1 ignored issue
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space

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...
27 10
        $result = $command([
1 ignored issue
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space

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...
28 10
            'version',
29 10
        ]);
30 8
        $lastVersion = 0;
31 8
        if (!empty($result)) {
32 8
            array_filter($result, function ($found) use (&$lastVersion) {
33 8
                $found = (int)$found['version'];
1 ignored issue
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 7 spaces but found 1 space

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...
34
                $lastVersion = $found > $lastVersion
35 8
                    ? $found
36 8
                    : $lastVersion;
37
38 8
                return false;
39 8
            });
40 8
        }
41
42 8
        return $lastVersion;
43
    }
44
}