EnumType::getSQLDeclaration()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 11
ccs 0
cts 7
cp 0
crap 2
rs 10
1
<?php
2
3
namespace CodexShaper\DBM\Database\Types\Mysql;
4
5
use CodexShaper\DBM\Database\Types\Type;
6
use Doctrine\DBAL\Platforms\AbstractPlatform;
7
use Illuminate\Support\Facades\DB;
8
9
class EnumType extends Type
10
{
11
    const NAME = 'enum';
12
13
    /**
14
     * Register enum type.
15
     *
16
     * @return string
17
     */
18
    public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
19
    {
20
        throw new \Exception('Enum type is not supported');
21
        $pdo = DB::connection()->getPdo();
0 ignored issues
show
Unused Code introduced by
$pdo = Illuminate\Suppor...:connection()->getPdo() is not reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
22
23
        // trim the values
24
        $allowed = array_map(function ($value) use ($pdo) {
25
            return $pdo->quote(trim($value));
26
        }, $allowed);
27
28
        return 'enum('.implode(', ', $allowed).')';
29
    }
30
}
31