Completed
Pull Request — master (#87)
by Maxime
01:35
created

AbstractEnumSQLDeclarationType   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 0
loc 14
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getSQLDeclaration() 0 8 1
1
<?php
2
3
/*
4
 * This file is part of the "elao/enum" package.
5
 *
6
 * Copyright (C) Elao
7
 *
8
 * @author Elao <[email protected]>
9
 */
10
11
namespace Elao\Enum\Bridge\Doctrine\DBAL\Types;
12
13
use Doctrine\DBAL\Platforms\AbstractPlatform;
14
15
/**
16
 * Base class for string enumerations with an `ENUM(...values)` column definition
17
 */
18
abstract class AbstractEnumSQLDeclarationType extends AbstractEnumType
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
24
    {
25
        $values = implode(', ', array_map(static function (string $value): string {
26
            return "'$value'";
27
        }, ($this->getEnumClass())::values()));
0 ignored issues
show
Bug introduced by
The method values cannot be called on $this->getEnumClass() (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
28
29
        return "ENUM($values)";
30
    }
31
}
32