Passed
Push — master ( f16abf...a45e17 )
by y
01:38
created

Predicate::lNot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Helix\DB\Fluent;
4
5
/**
6
 * A logical expression that evaluates to a boolean.
7
 */
8
class Predicate extends Expression implements ValueInterface
9
{
10
11
    /**
12
     * Logical `AND`
13
     *
14
     * `($this AND ...)`
15
     *
16
     * @param string ...$predicates
17
     * @return Predicate
18
     */
19
    public function lAnd(string ...$predicates)
20
    {
21
        array_unshift($predicates, $this);
22
        return static::factory($this->db, sprintf('(%s)', implode(' AND ', $predicates)));
23
    }
24
25
    /**
26
     * Logical `NOT`
27
     *
28
     * `NOT($this)`
29
     *
30
     * @return static
31
     */
32
    public function lNot()
33
    {
34
        return static::factory($this->db, "NOT({$this})");
35
    }
36
37
    /**
38
     * Logical `OR`
39
     *
40
     * `($this OR ...)`
41
     *
42
     * @param string ...$predicates
43
     * @return Predicate
44
     */
45
    public function lOr(string ...$predicates)
46
    {
47
        array_unshift($predicates, $this);
48
        return static::factory($this->db, sprintf('(%s)', implode(' OR ', $predicates)));
49
    }
50
51
}
52