Completed
Pull Request — master (#28)
by Tom
02:34
created

ServiceConfig::getKeys()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 9
rs 9.6666
cc 1
eloc 5
nc 1
nop 0
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