Completed
Push — master ( 79d213...eeff33 )
by Kamil
23:15
created

ConfigurationProcessingLoader   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 37
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A load() 0 11 2
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sylius\Bundle\ThemeBundle\Configuration\Loader;
13
14
use Sylius\Bundle\ThemeBundle\Configuration\Processor\ConfigurationProcessorInterface;
15
16
/**
17
 * @author Kamil Kokot <[email protected]>
18
 */
19
final class ConfigurationProcessingLoader implements ConfigurationLoaderInterface
20
{
21
    /**
22
     * @var ConfigurationLoaderInterface
23
     */
24
    private $decoratedLoader;
25
26
    /**
27
     * @var ConfigurationProcessorInterface
28
     */
29
    private $configurationProcessor;
30
31
    /**
32
     * @param ConfigurationLoaderInterface $decoratedLoader
33
     * @param ConfigurationProcessorInterface $configurationProcessor
34
     */
35
    public function __construct(ConfigurationLoaderInterface $decoratedLoader, ConfigurationProcessorInterface $configurationProcessor)
36
    {
37
        $this->decoratedLoader = $decoratedLoader;
38
        $this->configurationProcessor = $configurationProcessor;
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public function load($identifier)
45
    {
46
        $rawConfiguration = $this->decoratedLoader->load($identifier);
47
48
        $configurations = [$rawConfiguration];
49
        if (isset($rawConfiguration['extra']['sylius-theme'])) {
50
            $configurations[] = $rawConfiguration['extra']['sylius-theme'];
51
        }
52
53
        return $this->configurationProcessor->process($configurations);
54
    }
55
}
56