| Total Complexity | 10 |
| Total Lines | 47 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 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 |
|
| 58 | } |
||
| 59 | } |
||
| 60 |