MyCustomEnumType::getSQLDeclaration()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 8
rs 10
1
<?php
2
declare(strict_types=1);
3
4
namespace JDecool\Test\Doctrine\Type;
5
6
use Doctrine\DBAL\Platforms\AbstractPlatform;
7
use JDecool\Doctrine\Type\PhpEnumType;
8
use function call_user_func;
9
use function implode;
10
use function sprintf;
11
12
class MyCustomEnumType extends PhpEnumType
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17
    public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
18
    {
19
        $values = call_user_func([$this->enumClass, 'getConstants']);
20
21
        return sprintf(
22
            'ENUM("%s") COMMENT "%s"',
23
            implode('", "', $values),
24
            $this->getName()
25
        );
26
    }
27
}
28