CheckCompiler   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 8
c 1
b 0
f 0
dl 0
loc 13
ccs 7
cts 7
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A compile() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Umbrellio\Postgres\Compilers;
6
7
use Illuminate\Database\Schema\Blueprint;
8
use Illuminate\Database\Schema\Grammars\Grammar;
9
use Umbrellio\Postgres\Compilers\Traits\WheresBuilder;
10
use Umbrellio\Postgres\Schema\Builders\Constraints\Check\CheckBuilder;
11
12
class CheckCompiler
13
{
14
    use WheresBuilder;
15
16 3
    public static function compile(Grammar $grammar, Blueprint $blueprint, CheckBuilder $command): string
17
    {
18 3
        $wheres = static::build($grammar, $blueprint, $command);
19
20 3
        return sprintf(
21 3
            'ALTER TABLE %s ADD CONSTRAINT %s CHECK (%s)',
22 3
            $blueprint->getTable(),
23 3
            $command->get('index'),
24 3
            static::removeLeadingBoolean(implode(' ', $wheres))
25 3
        );
26
    }
27
}
28