Passed
Pull Request — 2.7 (#8122)
by Gildas
12:30
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
declare(strict_types=1);
3
4
namespace Doctrine\Tests\Models\CaseSensitiveDiscriminatorMap;
5
6
use Doctrine\ORM\Mapping\ClassMetadataInfo;
7
8
/**
9
 * @Entity
10
 * @InheritanceType("SINGLE_TABLE")
11
 * @DiscriminatorMap({"cube" = cube::class})
12
 * @DiscriminatorColumn(name="discr", length=32, type="string")
13
 */
14
abstract class Shape
15
{
16
    /** @Id @Column(type="string") @GeneratedValue(strategy="AUTO") */
17
    public $id;
18
19
    public static function loadMetadata(ClassMetadataInfo $metadata)
20
    {
21
        $metadata->setInheritanceType(ClassMetadataInfo::INHERITANCE_TYPE_SINGLE_TABLE);
22
        $metadata->setDiscriminatorColumn([
23
            'name' => 'discr',
24
            'type' => 'string',
25
            'length' => 32,
26
        ]);
27
        $metadata->setDiscriminatorMap([
28
            'cube' => cube::class,
29
        ]);
30
        $metadata->mapField([
31
            'fieldName' => 'id',
32
            'type' => 'string',
33
            'length' => NULL,
34
            'precision' => 0,
35
            'scale' => 0,
36
            'nullable' => false,
37
            'unique' => false,
38
            'id' => true,
39
            'columnName' => 'id',
40
        ]);
41
        $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO);
42
    }
43
}
44