ActionList::transformTokenToRoute()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 0
cts 8
cp 0
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 8
nc 3
nop 3
crap 12
1
<?php
2
namespace App\Actions\Image;
3
4
use League\Flysystem\FilesystemInterface;
5
use Staticus\Middlewares\ActionListAbstract;
6
use Staticus\Resources\Image\ResourceImageDO;
7
use Staticus\Resources\Image\ResourceImageDOInterface;
8
9
class ActionList extends ActionListAbstract
10
{
11
    public function __construct(
12
        ResourceImageDOInterface $resourceDO
13
        , FilesystemInterface $filesystem
14
    )
15
    {
16
        parent::__construct($resourceDO, $filesystem);
17
    }
18
19
    protected function allowedProperties()
20
    {
21
        $allowed = parent::allowedProperties();
22
        $allowed[] = ResourceImageDO::TOKEN_DIMENSION;
23
24
        return $allowed;
25
    }
26
27
    /**
28
     * @param string $token
29
     * @param string $value
30
     * @param array $query
31
     * @return array
32
     */
33
    protected function transformTokenToRoute($token, $value, array $query)
34
    {
35
        $query = parent::transformTokenToRoute($token, $value, $query);
36
        switch ($token) {
37
            case ResourceImageDO::TOKEN_DIMENSION:
38
                if ((int)$value !== ResourceImageDO::DEFAULT_DIMENSION) {
39
                    $query['size'] = $value;
40
                }
41
                break;
42
        }
43
44
        return $query;
45
    }
46
}