ProcessorsRegistry::add()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 3
cts 3
cp 1
rs 10
cc 1
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) 2017 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
    /**
30
     * ProcessorsRegistry constructor.
31
     *
32
     * @param ProcessorInterface[] $processors
33
     */
34 14
    public function __construct(array $processors = array())
35
    {
36 14
        $this->processors = array();
37
38 14
        foreach ($processors as $processor) {
39 1
            $this->add($processor);
40
        }
41 14
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46 1
    public function add(ProcessorInterface $processor)
47
    {
48 1
        $this->processors[] = $processor;
49 1
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54 1
    public function all()
55
    {
56 1
        return $this->processors;
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     */
62 1
    public function getIterator()
63
    {
64 1
        return new \ArrayIterator($this->processors);
65
    }
66
}
67