Completed
Push — master ( 2f2a87...25acd6 )
by Alessandro
01:48
created

Builder   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 61
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A and() 0 6 1
A or() 0 6 1
A getQueryFilters() 0 4 1
A expr() 0 4 1
1
<?php declare(strict_types = 1);
2
3
namespace Algatux\QueryBuilder;
4
5
use MongoDB\Collection;
6
7
/**
8
 * Class Builder.
9
 */
10
class Builder
11
{
12
    const COND_TYPE_AND = 1;
13
    const COND_TYPE_OR = 1;
14
15
    /** @var Collection */
16
    private $collection;
17
    /** @var Expression  */
18
    private $expression;
19
20
    /**
21
     * Builder constructor.
22
     *
23
     * @param Collection $collection
24
     */
25
    public function __construct(Collection $collection)
26
    {
27
        $this->collection = $collection;
28
        $this->expression = new Expression();
29
    }
30
31
    /**
32
     * @param array|Expression $expression
33
     *
34
     * @return $this
35
     */
36
    public function and($expression)
0 ignored issues
show
Unused Code introduced by
The parameter $expression is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
37
    {
38
        $this->expression->and(...func_get_args());
39
40
        return $this;
41
    }
42
43
    /**
44
     * @param array|Expression $expression
45
     *
46
     * @return $this
47
     */
48
    public function or($expression)
0 ignored issues
show
Unused Code introduced by
The parameter $expression is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
49
    {
50
        $this->expression->or(...func_get_args());
51
52
        return $this;
53
    }
54
55
    /**
56
     * @return array
57
     */
58
    public function getQueryFilters(): array
59
    {
60
        return $this->expression->getQueryPartial();
61
    }
62
63
    /**
64
     * @return Expression
65
     */
66
    public function expr(): Expression
67
    {
68
        return new Expression();
69
    }
70
}