OrX::asMongoObject()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 8
Ratio 100 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 8
loc 8
ccs 5
cts 5
cp 1
rs 9.4286
cc 1
eloc 5
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * This file is part of the SmartGecko(c) business platform.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace Governor\Framework\EventStore\Mongo\Criteria;
10
11
12
/**
13
 * Represents the OR operator for use by the Mongo Event Store.
14
 *
15
 * @author Allard Buijze
16
 * @since 2.0
17
 */
18 View Code Duplication
class OrX extends MongoCriteria {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
19
20
    /**
21
     * @var MongoCriteria
22
     */
23
    private $criteria1;
24
    /**
25
     * @var MongoCriteria
26
     */
27
    private $criteria2;
28
29
    /**
30
     * Initializes an OR operator where one of the given criteria must evaluate to <code>true</code>.
31
     *
32
     * @param MongoCriteria $criteria1 One of the criteria that must evaluate to true
33
     * @param MongoCriteria $criteria2 One of the criteria that must evaluate to true
34
     */
35 1
    public function __construct(MongoCriteria $criteria1, MongoCriteria $criteria2) {
36 1
        $this->criteria1 = $criteria1;
37 1
        $this->criteria2 = $criteria2;
38 1
    }
39
40
41 1
    public function asMongoObject() {
42
        return [
43
            '$or' => [
44 1
                $this->criteria1->asMongoObject(),
45 1
                $this->criteria2->asMongoObject()
46 1
            ]
47 1
        ];
48
    }
49
}