ActionPost   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 66.67%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 34
ccs 8
cts 12
cp 0.6667
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A generate() 0 18 3
A __construct() 0 8 1
1
<?php
2
namespace App\Actions\Image;
3
4
use League\Flysystem\FilesystemInterface;
5
use Staticus\Middlewares\ActionPostAbstract;
6
use Staticus\Resources\ResourceDOInterface;
7
use Staticus\Resources\Image\ResourceImageDOInterface;
8
use FractalManager\Manager as FractalManager;
9
10
class ActionPost extends ActionPostAbstract
11
{
12 4
    public function __construct(
13
        ResourceImageDOInterface $resourceDO
14
        , FilesystemInterface $filesystem
15
        , FractalManager $fractal
16
    )
17
    {
18 4
        parent::__construct($resourceDO, $filesystem, $fractal);
19 4
    }
20
21
    /**
22
     * @param ResourceDOInterface|ResourceImageDOInterface $resourceDO
23
     * @return mixed
24
     */
25 2
    protected function generate(ResourceDOInterface $resourceDO)
26
    {
27
        // Do not generate image when resizing or cropping is requested
28 2
        if ($this->resourceDO->getDimension()) {
29
30
            // If recreation for current size is asked, just remove previous file
31
            // Without this next middlewares will try to resize exist file
32
            if ($this->resourceDO->isRecreate()) {
33
                $this->filesystem->delete($this->resourceDO->getFilePath());
34
            }
35
36
            return null;
37
        }
38 2
        $query = $resourceDO->getName() . ' ' . $resourceDO->getNameAlternative();
39 2
        $content = $this->generator->generate($query);
40
41 2
        return $content;
42
    }
43
}