Completed
Push — master ( d1b735...0bfc48 )
by Daniel
08:29
created

Query::and()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Psi\Component\ObjectAgent\Query;
4
5
/**
6
 * Query::from(Foo::class)
7
 *   ->where(
8
 *       Query::and(
9
 *           Query::comparison('eq', 'foo', 'bar'),
10
 *           Query::comparison('gt', 10, 5),
11
 *       )
12
 *   );.
13
 */
14
final class Query
15
{
16
    private $classFqn;
17
    private $expression;
18
19
    private function __construct()
20
    {
21
    }
22
23
    public static function create(string $classFqn, Expression $expression)
24
    {
25
        $instance = new self();
26
        $instance->classFqn = $classFqn;
27
        $instance->expression = $expression;
28
29
        return $instance;
30
    }
31
32
    public function getClassFqn()
33
    {
34
        return $this->classFqn;
35
    }
36
37
    public function getExpression()
38
    {
39
        return $this->expression;
40
    }
41
42
    public static function comparison(string $comparator, $value1, $value2): Comparison
43
    {
44
        return new Comparison($comparator, $value1, $value2);
45
    }
46
47
    public static function composite($type, ...$expressions): Composite
48
    {
49
        return new Composite($type, $expressions);
50
    }
51
}
52