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

ConfigFactory::getProcessor()   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 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace kalanis\kw_images\Configs;
4
5
6
/**
7
 * Class ConfigFactory
8
 * Configuration for the whole processor
9
 * @package kalanis\kw_images\Graphics
10
 */
11
class ConfigFactory
12
{
13
    protected ProcessorConfig $processorConfig;
14
    protected ImageConfig $imageConfig;
15
    protected ThumbConfig $thumbConfig;
16
17 5
    public function __construct(
18
        ?ProcessorConfig $processorConfig = null,
19
        ?ImageConfig $imageConfig = null,
20
        ?ThumbConfig $thumbConfig = null
21
    )
22
    {
23 5
        $this->processorConfig = $processorConfig ?: new ProcessorConfig();
24 5
        $this->imageConfig = $imageConfig ?: new ImageConfig();
25 5
        $this->thumbConfig = $thumbConfig ?: new ThumbConfig();
26 5
    }
27
28
    /**
29
     * @param mixed $params
30
     * @return $this
31
     */
32 4
    public function setData($params): self
33
    {
34 4
        if (is_array($params)) {
35 4
            if (isset($params['images'])) {
36 1
                $this->setData($params['images']);
37
            }
38 4
            $this->processorConfig->setData($params);
39 4
            $this->imageConfig->setData($params);
40 4
            $this->thumbConfig->setData($params);
41
        }
42 4
        return $this;
43
    }
44
45 2
    public function getProcessor(): ProcessorConfig
46
    {
47 2
        return $this->processorConfig;
48
    }
49
50 2
    public function getImage(): ImageConfig
51
    {
52 2
        return $this->imageConfig;
53
    }
54
55 4
    public function getThumb(): ThumbConfig
56
    {
57 4
        return $this->thumbConfig;
58
    }
59
}
60