Completed
Push — master ( 670622...a5ffbc )
by Edson
01:42
created

Operators::not()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Keep;
4
5
trait Operators
6
{
7
    private $operators = '';
8
    private $attributes = [];
9
10 2
    public function and(string $key = null, $value): self
11
    {
12 2
        return (!$key) ? $this : $this->operator('AND', $key, $value);
13
    }
14
15 2
    public function or(string $key = null, $value): self
16
    {
17 2
        return (!$key) ? $this : $this->operator('OR', $key, $value);
18
    }
19
20 2
    public function not(string $key, $value): self
21
    {
22 2
        return $this->operator('NOT', $key, $value);
23
    }
24
25 6
    private function operator(string $operator, string $key, $value): self
26
    {
27 6
        $this->attributes[$key] = $value;
28 6
        $this->operators .= "{$operator} `{$key}` = :{$key}";
29 6
        return $this;
30
    }
31
}
32