Completed
Pull Request — master (#1263)
by Andreas
10:33
created

Match::expr()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 7
ccs 0
cts 6
cp 0
rs 9.4286
cc 1
eloc 4
nc 1
nop 0
crap 2
1
<?php
2
/*
3
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 *
15
 * This software consists of voluntary contributions made by many individuals
16
 * and is licensed under the MIT license. For more information, see
17
 * <http://www.doctrine-project.org>.
18
 */
19
20
namespace Doctrine\ODM\MongoDB\Aggregation\Stage;
21
22
use Doctrine\MongoDB\Aggregation\Stage as BaseStage;
23
use Doctrine\ODM\MongoDB\Aggregation\Builder;
24
use Doctrine\ODM\MongoDB\DocumentManager;
25
use Doctrine\ODM\MongoDB\Mapping\ClassMetadata;
26
use Doctrine\ODM\MongoDB\Query\Expr;
27
28
/**
29
 * Fluent interface for building aggregation pipelines.
30
 *
31
 * @author alcaeus <[email protected]>
32
 */
33
class Match extends BaseStage\Match
34
{
35
    /**
36
     * @var DocumentManager
37
     */
38
    private $dm;
39
40
    /**
41
     * @var ClassMetadata
42
     */
43
    private $class;
44
45
    /**
46
     * @inheritDoc
47
     */
48
    public function __construct(Builder $builder, DocumentManager $dm, ClassMetadata $class)
49
    {
50
        parent::__construct($builder);
51
52
        $this->dm = $dm;
53
        $this->class = $class;
54
        $this->expr = $this->expr();
0 ignored issues
show
Bug introduced by
The property expr does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
55
    }
56
57
    /**
58
     * @inheritDoc
59
     */
60
    public function expr()
61
    {
62
        $expr = new Expr($this->dm);
63
        $expr->setClassMetadata($this->class);
64
65
        return $expr;
66
    }
67
}
68