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

ProcessorConfig   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 38
ccs 14
cts 14
cp 1
rs 10
wmc 9

5 Methods

Rating   Name   Duplication   Size   Complexity  
A canLimitSize() 0 3 1
A setData() 0 7 5
A canLimitExt() 0 3 1
A getDefaultExt() 0 3 1
A hasThumb() 0 3 1
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