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

ConfigFactory   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 47
ccs 19
cts 19
cp 1
rs 10
wmc 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getThumb() 0 3 1
A getImage() 0 3 1
A setData() 0 11 3
A getProcessor() 0 3 1
A __construct() 0 9 4
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