Completed
Push — master ( fd6b18...202a78 )
by Nikola
03:09
created

ProcessorsRegistry::add()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
/*
3
 * This file is part of the Exchange Rate package, an RunOpenCode project.
4
 *
5
 * (c) 2016 RunOpenCode
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace RunOpenCode\ExchangeRate\Registry;
11
12
use RunOpenCode\ExchangeRate\Contract\ProcessorInterface;
13
use RunOpenCode\ExchangeRate\Contract\ProcessorsRegistryInterface;
14
15
/**
16
 * Class ProcessorsRegistry
17
 *
18
 * Default implementation of processor registry.
19
 *
20
 * @package RunOpenCode\ExchangeRate\Registry
21
 */
22
final class ProcessorsRegistry implements ProcessorsRegistryInterface
23
{
24
    /**
25
     * @var ProcessorInterface[]
26
     */
27
    private $processors;
28
29 2
    public function __construct(array $processors = array())
30
    {
31 2
        $this->processors = array();
32
33 2
        foreach ($processors as $processor) {
34 2
            $this->add($processor);
35 2
        }
36 2
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41 2
    public function add(ProcessorInterface $processor)
42
    {
43 2
        $this->processors[] = $processor;
44 2
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49 2
    public function all()
50
    {
51 2
        return $this->processors;
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57 2
    public function getIterator()
58
    {
59 2
        return new \ArrayIterator($this->processors);
60
    }
61
}
62