Completed
Pull Request — master (#28)
by Tom
27:09
created

ServiceConfig::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 6
rs 9.4285
cc 2
eloc 3
nc 2
nop 1
1
<?php
2
3
namespace TomPHP\ConfigServiceProvider;
4
5
use ArrayIterator;
6
use IteratorAggregate;
7
8
final class ServiceConfig implements IteratorAggregate
9
{
10
    /**
11
     * @var ServiceDefinition[]
12
     */
13
    private $config = [];
14
15
    public function __construct(array $config)
16
    {
17
        foreach ($config as $key => $serviceConfig) {
18
            $this->config[] = new ServiceDefinition($key, $serviceConfig);
19
        }
20
    }
21
22
    /**
23
     * @return array
24
     */
25
    public function getKeys()
26
    {
27
        return array_map(
28
            function (ServiceDefinition $definition) {
29
                return $definition->getName();
30
            },
31
            $this->config
32
        );
33
    }
34
35
    public function getIterator()
36
    {
37
        return new ArrayIterator($this->config);
38
    }
39
}
40