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

Operators   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 25
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A not() 0 3 1
A or() 0 3 2
A operator() 0 5 1
A and() 0 3 2
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