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

injectEnvironmentAndConfigurationIfNeeded()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 6
rs 10
cc 2
nc 2
nop 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