Passed
Push — master ( 1543d0...69c5f0 )
by Petr
08:19
created

ImageConfig::getMaxFileSize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace kalanis\kw_images\Graphics;
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 21
    public function setData(array $params = []): self
28
    {
29 21
        $this->maxInWidth = !empty($params['max_upload_width']) ? intval(strval($params['max_upload_width'])) : $this->maxInWidth;
30 21
        $this->maxInHeight = !empty($params['max_upload_height']) ? intval(strval($params['max_upload_height'])) : $this->maxInHeight;
31 21
        $this->maxStoreWidth = !empty($params['max_width']) ? intval(strval($params['max_width'])) : $this->maxStoreWidth;
32 21
        $this->maxStoreHeight = !empty($params['max_height']) ? intval(strval($params['max_height'])) : $this->maxStoreHeight;
33 21
        $this->maxFileSize = !empty($params['max_size']) ? intval(strval($params['max_size'])) : $this->maxFileSize;
34 21
        $this->tempPrefix = !empty($params['tmp_pref']) ? strval($params['tmp_pref']) : $this->tempPrefix;
35 21
        return $this;
36
    }
37
38 4
    public function getMaxInWidth(): int
39
    {
40 4
        return $this->maxInWidth;
41
    }
42
43 5
    public function getMaxInHeight(): int
44
    {
45 5
        return $this->maxInHeight;
46
    }
47
48 7
    public function getMaxStoreWidth(): int
49
    {
50 7
        return $this->maxStoreWidth;
51
    }
52
53 7
    public function getMaxStoreHeight(): int
54
    {
55 7
        return $this->maxStoreHeight;
56
    }
57
58 6
    public function getMaxFileSize(): int
59
    {
60 6
        return $this->maxFileSize;
61
    }
62
63 8
    public function getTempPrefix(): string
64
    {
65 8
        return $this->tempPrefix;
66
    }
67
}
68