Code Duplication    Length = 32-34 lines in 2 locations

src/Governor/Framework/EventStore/Mongo/Criteria/AndX.php 1 location

@@ 18-51 (lines=34) @@
15
 * @author Allard Buijze
16
 * @since 2.0
17
 */
18
class AndX extends MongoCriteria {
19
20
    /**
21
     * @var MongoCriteria
22
     */
23
    private $criteria1;
24
    /**
25
     * @var MongoCriteria
26
     */
27
    private $criteria2;
28
29
    /**
30
     * Returns a criterium that requires both <code>criteria1</code> and <code>criteria2</code>  to be
31
     * <code>true</code>.
32
     *
33
     * @param MongoCriteria $criteria1 One of the criteria that must evaluate to true
34
     * @param MongoCriteria $criteria2 One of the criteria that must evaluate to true
35
     */
36
    public function __construct(MongoCriteria $criteria1, MongoCriteria $criteria2)
37
    {
38
        $this->criteria1 = $criteria1;
39
        $this->criteria2 = $criteria2;
40
    }
41
42
43
    public function asMongoObject() {
44
        return [
45
            '$and' => [
46
                $this->criteria1->asMongoObject(),
47
                $this->criteria2->asMongoObject()
48
            ]
49
        ];
50
    }
51
}

src/Governor/Framework/EventStore/Mongo/Criteria/OrX.php 1 location

@@ 18-49 (lines=32) @@
15
 * @author Allard Buijze
16
 * @since 2.0
17
 */
18
class OrX extends MongoCriteria {
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
    public function __construct(MongoCriteria $criteria1, MongoCriteria $criteria2) {
36
        $this->criteria1 = $criteria1;
37
        $this->criteria2 = $criteria2;
38
    }
39
40
41
    public function asMongoObject() {
42
        return [
43
            '$or' => [
44
                $this->criteria1->asMongoObject(),
45
                $this->criteria2->asMongoObject()
46
            ]
47
        ];
48
    }
49
}