Passed
Push — master ( 267be1...4d09e6 )
by Eugene
03:12
created

DeleteImageSizesResourceCommand   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 1 Features 1
Metric Value
wmc 7
c 4
b 1
f 1
lcom 1
cbo 3
dl 0
loc 45
ccs 25
cts 25
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A __invoke() 0 4 1
B execute() 0 22 5
1
<?php
2
namespace Staticus\Resources\Commands;
3
4
use League\Flysystem\FilesystemInterface;
5
use Staticus\Resources\Image\ResourceImageDO;
6
use Staticus\Resources\Image\ResourceImageDOInterface;
7
8
class DeleteImageSizesResourceCommand implements ResourceCommandInterface
9
{
10
    /**
11
     * @var ResourceImageDOInterface
12
     */
13
    protected $resourceDO;
14
    /**
15
     * @var FilesystemInterface
16
     */
17
    protected $filesystem;
18
19 3
    public function __construct(ResourceImageDOInterface $resourceDO, FilesystemInterface $filesystem)
20
    {
21 3
        $this->resourceDO = $resourceDO;
22 3
        $this->filesystem = $filesystem;
23 3
    }
24
25 3
    public function __invoke()
26
    {
27 3
        return $this->execute();
28
    }
29
30 3
    protected function execute()
31
    {
32 3
        $command = new FindResourceOptionsCommand($this->resourceDO, $this->filesystem);
33 3
        $result = $command([
1 ignored issue
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 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 3
            ResourceImageDO::TOKEN_DIMENSION,
35 3
        ]);
36 2
        foreach ($result as $dimension) {
37 1
            $dimension = array_key_exists(ResourceImageDO::TOKEN_DIMENSION, $dimension)
38 1
                ? $dimension[ResourceImageDO::TOKEN_DIMENSION]
39 1
                : '';
40 1
            $dimension = explode('x', $dimension);
41 1
            if (false !== $dimension && 2 === count($dimension)) {
42 1
                $destroyDO = clone $this->resourceDO;
43 1
                $destroyDO->setWidth($dimension[0]);
44 1
                $destroyDO->setHeight($dimension[1]);
45 1
                $command = new DestroyResourceCommand($destroyDO, $this->filesystem);
46 1
                $command(true);
47 1
            }
48 2
        }
49
50 2
        return true;
51
    }
52
}