Passed
Push — master ( 69c5f0...efe757 )
by Petr
02:32
created

ProcessorConfig::setData()   A

Complexity

Conditions 5
Paths 16

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 5
eloc 5
c 1
b 0
f 0
nc 16
nop 1
dl 0
loc 7
ccs 6
cts 6
cp 1
crap 5
rs 9.6111
1
<?php
2
3
namespace kalanis\kw_images\Configs;
4
5
6
/**
7
 * Class ProcessorConfig
8
 * Configuration for the whole processor
9
 * @package kalanis\kw_images\Graphics
10
 */
11
class ProcessorConfig
12
{
13
    protected bool $createThumb = true;
14
    protected bool $wantLimitSize = false;
15
    protected bool $wantLimitExt = false;
16
    protected string $defaultExt = 'jpg';
17
18
    /**
19
     * @param array<string, string|int> $params
20
     * @return $this
21
     */
22 7
    public function setData(array $params = []): self
23
    {
24 7
        $this->createThumb = isset($params['create_thumb']) ? boolval(intval(strval($params['create_thumb']))) : $this->createThumb;
25 7
        $this->wantLimitSize = isset($params['want_limit_size']) ? boolval(intval(strval($params['want_limit_size']))) : $this->wantLimitSize;
26 7
        $this->wantLimitExt = isset($params['want_limit_ext']) ? boolval(intval(strval($params['want_limit_ext']))) : $this->wantLimitExt;
27 7
        $this->defaultExt = !empty($params['default_ext']) ? strval($params['default_ext']) : $this->defaultExt;
28 7
        return $this;
29
    }
30
31 3
    public function getDefaultExt(): string
32
    {
33 3
        return $this->defaultExt;
34
    }
35
36 3
    public function canLimitExt(): bool
37
    {
38 3
        return $this->wantLimitExt;
39
    }
40
41 3
    public function canLimitSize(): bool
42
    {
43 3
        return $this->wantLimitSize;
44
    }
45
46 3
    public function hasThumb(): bool
47
    {
48 3
        return $this->createThumb;
49
    }
50
}
51