InheritanceFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 27
ccs 4
cts 4
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 8 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