Code Duplication    Length = 23-26 lines in 2 locations

Core/Matcher/AbstractMatcher.php 2 locations

@@ 34-59 (lines=26) @@
31
        }
32
    }
33
34
    protected function matchAnd($conditionsArray)
35
    {
36
        if (!is_array($conditionsArray) || !count($conditionsArray)) {
37
            throw new \Exception($this->returns . " can not be matched because no matching conditions found for 'and' clause.");
38
        }
39
40
        $class = null;
41
        foreach ($conditionsArray as $conditions) {
42
            $out = $this->match($conditions);
43
            if ($out instanceof \ArrayObject) {
44
                $class = get_class($out);
45
                $out = $out->getArrayCopy();
46
            }
47
            if (!isset($results)) {
48
                $results = $out;
49
            } else {
50
                $results = array_intersect_key($results, $out);
51
            }
52
        }
53
54
        if ($class) {
55
            $results = new $class($results);
56
        }
57
58
        return $results;
59
    }
60
61
    protected function matchOr(array $conditionsArray)
62
    {
@@ 61-83 (lines=23) @@
58
        return $results;
59
    }
60
61
    protected function matchOr(array $conditionsArray)
62
    {
63
        if (!is_array($conditionsArray) || !count($conditionsArray)) {
64
            throw new \Exception($this->returns . " can not be matched because no matching conditions found for 'or' clause.");
65
        }
66
67
        $class = null;
68
        $results = array();
69
        foreach ($conditionsArray as $conditions) {
70
            $out = $this->match($conditions);
71
            if ($out instanceof \ArrayObject) {
72
                $class = get_class($out);
73
                $out = $out->getArrayCopy();
74
            }
75
            $results = array_replace($results, $out);
76
        }
77
78
        if ($class) {
79
            $results = new $class($results);
80
        }
81
82
        return $results;
83
    }
84
85
    public function matchOne(array $conditions)
86
    {