Completed
Push — master ( 5e4c69...6bf127 )
by Tom
02:18
created

ServiceConfig   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
c 1
b 0
f 1
lcom 1
cbo 1
dl 0
loc 32
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 2
A getKeys() 0 9 1
A getIterator() 0 4 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