Factory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 83.33%

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 13
ccs 5
cts 6
cp 0.8333
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A buildFromString() 0 11 3
1
<?php
2
3
namespace CompoLab\Domain\Type;
4
5
final class Factory
6
{
7 7
    public static function buildFromString(string $string): Type
8
    {
9 7
        if (preg_match('/^git$/i', $string)) {
10 6
            return new Git;
11
        }
12
13 2
        if (preg_match('/^tar$/i', $string)) {
14 2
            return new Tar;
15
        }
16
17
        throw new \RuntimeException(sprintf('Impossible to create a type from string "%s"', $string));
18
    }
19
}
20