Passed
Pull Request — 2.7 (#8122)
by Gildas
07:09
created

Shape::loadMetadata()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 18
c 1
b 0
f 0
dl 0
loc 23
rs 9.6666
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Tests\Models\CaseSensitiveDiscriminatorMap;
6
7
use Doctrine\ORM\Mapping\ClassMetadataInfo;
8
9
/**
10
 * @Entity
11
 * @InheritanceType("SINGLE_TABLE")
12
 * @DiscriminatorMap({"cube" = cube::class})
13
 * @DiscriminatorColumn(name="discr", length=32, type="string")
14
 */
15
abstract class Shape
16
{
17
    /** @Id @Column(type="string") @GeneratedValue(strategy="AUTO") */
18
    public $id;
19
20
    public static function loadMetadata(ClassMetadataInfo $metadata)
21
    {
22
        $metadata->setInheritanceType(ClassMetadataInfo::INHERITANCE_TYPE_SINGLE_TABLE);
23
        $metadata->setDiscriminatorColumn([
24
            'name' => 'discr',
25
            'type' => 'string',
26
            'length' => 32,
27
        ]);
28
        $metadata->setDiscriminatorMap([
29
            'cube' => cube::class,
30
        ]);
31
        $metadata->mapField([
32
            'fieldName' => 'id',
33
            'type' => 'string',
34
            'length' => null,
35
            'precision' => 0,
36
            'scale' => 0,
37
            'nullable' => false,
38
            'unique' => false,
39
            'id' => true,
40
            'columnName' => 'id',
41
        ]);
42
        $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO);
43
    }
44
}
45