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

RatesConfigurationRegistry   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 41
ccs 0
cts 26
cp 0
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A add() 0 4 1
A find() 0 16 3
A all() 0 4 1
A getIterator() 0 4 1
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