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

RatesConfigurationRegistry::__construct()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

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