Passed
Pull Request — latest (#3)
by Mark
35:03
created

AbstractConfigurableEnvironment   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 6
c 1
b 0
f 0
dl 0
loc 18
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A injectEnvironmentAndConfigurationIfNeeded() 0 6 2
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace UnicornFail\Emoji\Environment;
6
7
use UnicornFail\Emoji\Configuration\Configuration;
8
use UnicornFail\Emoji\Configuration\ConfigurationAwareInterface;
9
use UnicornFail\Emoji\Traits\ConfigurableEnvironmentTrait;
10
11
class AbstractConfigurableEnvironment extends AbstractEnvironment implements ConfigurableEnvironmentInterface
12
{
13
    use ConfigurableEnvironmentTrait;
14
15
    /**
16
     * @param mixed[]|\Traversable $configuration
17
     */
18
    public function __construct(?iterable $configuration = null)
19
    {
20
        $this->configuration = Configuration::create($configuration);
21
    }
22
23
    protected function injectEnvironmentAndConfigurationIfNeeded(object $object): void
24
    {
25
        parent::injectEnvironmentAndConfigurationIfNeeded($object);
26
27
        if ($object instanceof ConfigurationAwareInterface) {
28
            $object->setConfiguration($this->getConfiguration());
29
        }
30
    }
31
}
32