WhereBuilderTrait   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 12
eloc 13
dl 0
loc 53
ccs 21
cts 21
cp 1
rs 10
c 0
b 0
f 0

10 Methods

Rating   Name   Duplication   Size   Complexity  
A whereNotBetween() 0 3 1
A whereIn() 0 3 2
A whereNull() 0 3 2
A where() 0 3 1
A whereColumn() 0 3 1
A whereRaw() 0 3 1
A whereNotNull() 0 3 1
A whereBetween() 0 3 1
A whereNotIn() 0 3 1
A compileWhere() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Umbrellio\Postgres\Schema\Builders;
6
7
use Illuminate\Support\Fluent;
8
9
/**
10
 * @see Fluent
11
 */
12
trait WhereBuilderTrait
13
{
14
    protected $attributes = [];
15
16 2
    public function whereRaw(string $sql, array $bindings = [], string $boolean = 'and'): self
17
    {
18 2
        return $this->compileWhere('Raw', $boolean, compact('sql', 'bindings'));
19
    }
20
21 2
    public function where(string $column, string $operator, string $value, string $boolean = 'and'): self
22
    {
23 2
        return $this->compileWhere('Basic', $boolean, compact('column', 'operator', 'value'));
24
    }
25
26 3
    public function whereColumn(string $first, string $operator, string $second, string $boolean = 'and'): self
27
    {
28 3
        return $this->compileWhere('Column', $boolean, compact('first', 'operator', 'second'));
29
    }
30
31 5
    public function whereIn(string $column, array $values, string $boolean = 'and', bool $not = false): self
32
    {
33 5
        return $this->compileWhere($not ? 'NotIn' : 'In', $boolean, compact('column', 'values'));
34
    }
35
36 2
    public function whereNotIn(string $column, array $values = [], string $boolean = 'and'): self
37
    {
38 2
        return $this->whereIn($column, $values, $boolean, true);
39
    }
40
41 6
    public function whereNull(string $column, string $boolean = 'and', bool $not = false): self
42
    {
43 6
        return $this->compileWhere($not ? 'NotNull' : 'Null', $boolean, compact('column'));
44
    }
45
46 2
    public function whereBetween(string $column, array $values = [], string $boolean = 'and', bool $not = false): self
47
    {
48 2
        return $this->compileWhere('Between', $boolean, compact('column', 'values', 'not'));
49
    }
50
51 1
    public function whereNotBetween(string $column, array $values = [], string $boolean = 'and'): self
52
    {
53 1
        return $this->whereBetween($column, $values, $boolean, true);
54
    }
55
56 2
    public function whereNotNull(string $column, string $boolean = 'and'): self
57
    {
58 2
        return $this->whereNull($column, $boolean, true);
59
    }
60
61 18
    protected function compileWhere(string $type, string $boolean, array $parameters = []): self
62
    {
63 18
        $this->attributes['wheres'][] = array_merge(compact('type', 'boolean'), $parameters);
64 18
        return $this;
65
    }
66
}
67