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

ImageConfig::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 ImageConfig
11
 * Configuration for main image itself
12
 * @package kalanis\kw_images\Graphics
13
 */
14
class ImageConfig implements ISizes
15
{
16
    protected int $maxInWidth = 16384;
17
    protected int $maxInHeight = 16384;
18
    protected int $maxStoreWidth = 1024;
19
    protected int $maxStoreHeight = 1024;
20
    protected int $maxFileSize = 10485760;
21
    protected string $tempPrefix = '';
22
23
    /**
24
     * @param array<string, string|int> $params
25
     * @return $this
26
     */
27 24
    public function setData(array $params = []): self
28
    {
29 24
        $this->maxInWidth = !empty($params['max_upload_width']) ? intval(strval($params['max_upload_width'])) : $this->maxInWidth;
30 24
        $this->maxInHeight = !empty($params['max_upload_height']) ? intval(strval($params['max_upload_height'])) : $this->maxInHeight;
31 24
        $this->maxStoreWidth = !empty($params['max_width']) ? intval(strval($params['max_width'])) : $this->maxStoreWidth;
32 24
        $this->maxStoreHeight = !empty($params['max_height']) ? intval(strval($params['max_height'])) : $this->maxStoreHeight;
33 24
        $this->maxFileSize = !empty($params['max_size']) ? intval(strval($params['max_size'])) : $this->maxFileSize;
34 24
        $this->tempPrefix = !empty($params['tmp_pref']) ? strval($params['tmp_pref']) : $this->tempPrefix;
35 24
        return $this;
36
    }
37
38 5
    public function getMaxInWidth(): int
39
    {
40 5
        return $this->maxInWidth;
41
    }
42
43 6
    public function getMaxInHeight(): int
44
    {
45 6
        return $this->maxInHeight;
46
    }
47
48 8
    public function getMaxStoreWidth(): int
49
    {
50 8
        return $this->maxStoreWidth;
51
    }
52
53 8
    public function getMaxStoreHeight(): int
54
    {
55 8
        return $this->maxStoreHeight;
56
    }
57
58 7
    public function getMaxFileSize(): int
59
    {
60 7
        return $this->maxFileSize;
61
    }
62
63 9
    public function getTempPrefix(): string
64
    {
65 9
        return $this->tempPrefix;
66
    }
67
}
68