FieldParserRegistry   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 27
ccs 6
cts 7
cp 0.8571
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addParser() 0 3 1
A getParser() 0 7 2
1
<?php
2
3
namespace Graze\CiffRenderer\Parser;
4
5
use Graze\CiffRenderer\Parser\FieldParser\FieldParserInterface;
6
use Graze\CiffRenderer\Exception\RuntimeException;
7
8
class FieldParserRegistry
9
{
10
    /**
11
     * @var FieldParserInterface[]
12
     */
13
    private $parsers;
14
15
    /**
16
     * @param FieldParserInterface $parser
17
     */
18 1
    public function addParser(FieldParserInterface $parser)
19
    {
20 1
        $this->parsers[$parser->getFieldName()] = $parser;
21 1
    }
22
23
    /**
24
     * @param string $name
25
     * @return FieldParserInterface
26
     * @throws RuntimeException
27
     */
28 1
    public function getParser($name)
29
    {
30 1
        if (!isset($this->parsers[$name])) {
31
            throw new RuntimeException(sprintf('Parser does not exist [%s]', $name));
32
        }
33
34 1
        return $this->parsers[$name];
35
    }
36
}
37