Completed
Push — master ( 17fbce...9c0ecb )
by Nikola
02:12
created

RatesConfigurationRegistry::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace RunOpenCode\ExchangeRate\Registry;
4
5
use RunOpenCode\ExchangeRate\Configuration;
6
use RunOpenCode\ExchangeRate\Contract\RatesConfigurationRegistryInterface;
7
8
class RatesConfigurationRegistry implements RatesConfigurationRegistryInterface
9
{
10
    protected $configurations;
11
12
    public function __construct()
13
    {
14
        $this->configurations = array();
15
    }
16
17
    public function add(Configuration $configuration)
18
    {
19
        $this->configurations[] = $configuration;
20
    }
21
22
    public function find($sourceName)
23
    {
24
        $result = array();
25
26
        /**
27
         * @var Configuration $configuration
28
         */
29
        foreach ($this->configurations as $configuration) {
30
31
            if ($configuration->getSource() == $sourceName) {
32
                $result[] = $configuration;
33
            }
34
        }
35
36
        return $result;
37
    }
38
39
    public function all()
40
    {
41
        return $this->configurations;
42
    }
43
44
    public function getIterator()
45
    {
46
        return new \ArrayIterator($this->configurations);
47
    }
48
}
49