Passed
Push — master ( bbc85b...f0bc06 )
by
04:59
created

Factory::createFromProp()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 5
c 0
b 0
f 0
nc 2
nop 1
dl 0
loc 8
ccs 6
cts 6
cp 1
crap 2
rs 10
1
<?php
2
declare(strict_types=1);
3
4
namespace Ely\Mojang\Response\Properties;
5
6
class Factory {
7
8
    private static $MAP = [
9
        'textures' => TexturesProperty::class,
10
    ];
11
12 6
    public static function createFromProp(array $prop): Property {
13 6
        $name = $prop['name'];
14 6
        if (isset(self::$MAP[$name])) {
15 3
            $className = self::$MAP[$name];
16 3
            return new $className($prop);
17
        }
18
19 3
        return new Property($prop);
20
    }
21
22
}
23