ParserFactory::create()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Amock\Parser;
4
5
class ParserFactory
6
{
7
    const TYPE_YAML = 'yaml';
8
9 10
    public static function create(string $type): Parser
10
    {
11
        switch ($type) {
12 10
            case static::TYPE_YAML:
13 9
                return new YamlParser();
14
            default:
15 1
                throw new Exception\InvalidParserException($type);
16
        }
17
    }
18
}
19