Completed
Push — master ( 42f99d...2335a8 )
by Nikola
18:20 queued 03:48
created

RatesConfigurationRegistry   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 42
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 3
A getIterator() 0 4 1
A add() 0 4 1
A all() 0 4 1
1
<?php
2
3
namespace RunOpenCode\Bundle\ExchangeRate\Registry;
4
5
use RunOpenCode\ExchangeRate\Configuration;
6
use RunOpenCode\ExchangeRate\Contract\RatesConfigurationRegistryInterface;
7
use RunOpenCode\ExchangeRate\Registry\RatesConfigurationRegistry as BaseRatesConfigurationRegistry;
8
9
final class RatesConfigurationRegistry implements RatesConfigurationRegistryInterface
10
{
11
    private $registry;
12
13
    public function __construct(array $registeredRates)
14
    {
15
        $this->registry = new BaseRatesConfigurationRegistry();
16
17
        foreach ($registeredRates as $registeredRate) {
18
            $this->add( new Configuration(
19
                $registeredRate['currency_code'],
20
                $registeredRate['rate_type'],
21
                $registeredRate['source'],
22
                !empty($registeredRate['extra']) ? $registeredRate['extra'] : array()
23
            ));
24
        }
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function getIterator()
31
    {
32
        return $this->registry->getIterator();
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function add(Configuration $configuration)
39
    {
40
        $this->registry->add($configuration);
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function all(array $filter = array())
47
    {
48
        return $this->registry->all($filter);
49
    }
50
}
51