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

ThumbConfig::setData()   B

Complexity

Conditions 7
Paths 64

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 7

Importance

Changes 0
Metric Value
cc 7
eloc 7
c 0
b 0
f 0
nc 64
nop 1
dl 0
loc 9
ccs 8
cts 8
cp 1
crap 7
rs 8.8333
1
<?php
2
3
namespace kalanis\kw_images\Configs;
4
5
6
use kalanis\kw_images\Interfaces\ISizes;
7
8
9
/**
10
 * Class ThumbConfig
11
 * File thumbnail configuration
12
 * @package kalanis\kw_images\Configs
13
 */
14
class ThumbConfig implements ISizes
15
{
16
    const FILE_TEMP = 'thumb_tmp';
17
18
    protected int $maxInWidth = 16384;
19
    protected int $maxInHeight = 16384;
20
    protected int $maxWidth = 180;
21
    protected int $maxHeight = 180;
22
    protected int $maxFileSize = 10485760;
23
    protected string $tempPrefix = self::FILE_TEMP;
24
25
    /**
26
     * @param array<string, string|int> $params
27
     * @return $this
28
     */
29 7
    public function setData(array $params = []): self
30
    {
31 7
        $this->maxInWidth = !empty($params['max_upload_width']) ? intval(strval($params['max_upload_width'])) : $this->maxInWidth;
32 7
        $this->maxInHeight = !empty($params['max_upload_height']) ? intval(strval($params['max_upload_height'])) : $this->maxInHeight;
33 7
        $this->maxWidth = !empty($params['tmb_width']) ? intval(strval($params['tmb_width'])) : $this->maxWidth;
34 7
        $this->maxHeight = !empty($params['tmb_height']) ? intval(strval($params['tmb_height'])) : $this->maxHeight;
35 7
        $this->maxFileSize = !empty($params['tmb_size']) ? intval(strval($params['tmb_size'])) : $this->maxFileSize;
36 7
        $this->tempPrefix = !empty($params['temp_pref']) ? strval($params['temp_pref']) : $this->tempPrefix;
37 7
        return $this;
38
    }
39
40 2
    public function getMaxInWidth(): int
41
    {
42 2
        return $this->maxInWidth;
43
    }
44
45 2
    public function getMaxInHeight(): int
46
    {
47 2
        return $this->maxInHeight;
48
    }
49
50 3
    public function getMaxStoreWidth(): int
51
    {
52 3
        return $this->maxWidth;
53
    }
54
55 3
    public function getMaxStoreHeight(): int
56
    {
57 3
        return $this->maxHeight;
58
    }
59
60 2
    public function getMaxFileSize(): int
61
    {
62 2
        return $this->maxFileSize;
63
    }
64
65 3
    public function getTempPrefix(): string
66
    {
67 3
        return $this->tempPrefix;
68
    }
69
}
70