InheritanceFactory::create()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 2
crap 2
1
<?php
2
3
namespace LaravelDoctrine\Fluent\Builders\Inheritance;
4
5
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
6
use InvalidArgumentException;
7
8
class InheritanceFactory
9
{
10
    /**
11
     * @var array
12
     */
13
    protected static $map = [
14
        'JOINED'            => JoinedTableInheritance::class,
15
        'SINGLE_TABLE'      => SingleTableInheritance::class,
16
        Inheritance::SINGLE => SingleTableInheritance::class,
17
        Inheritance::JOINED => JoinedTableInheritance::class
18
    ];
19
20
    /**
21
     * @param string               $type
22
     * @param ClassMetadataBuilder $builder
23
     *
24
     * @return Inheritance
25
     */
26 8
    public static function create($type, ClassMetadataBuilder $builder)
27
    {
28 8
        if (isset(static::$map[$type])) {
29 7
            return new static::$map[$type]($builder);
30
        }
31
32 1
        throw new InvalidArgumentException("Inheritance type [{$type}] does not exist. SINGLE_TABLE and JOINED are support");
33
    }
34
}
35