SetType::getSQLDeclaration()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 14
ccs 0
cts 8
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 SetType extends Type
10
{
11
    const NAME = 'set';
12
13
    /**
14
     * Register set type.
15
     *
16
     * @return string
17
     */
18
    public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
19
    {
20
        throw new \Exception('Set type is not supported');
21
        // we're going to store SET values in the comment since DBAL doesn't support
22
        $allowed = explode(',', trim($fieldDeclaration['comment']));
0 ignored issues
show
Unused Code introduced by
$allowed = explode(',', ...eclaration['comment'])) 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...
23
24
        $pdo = DB::connection()->getPdo();
25
26
        // trim the values
27
        $fieldDeclaration['allowed'] = array_map(function ($value) use ($pdo) {
28
            return $pdo->quote(trim($value));
29
        }, $allowed);
30
31
        return 'set('.implode(', ', $fieldDeclaration['allowed']).')';
32
    }
33
}
34