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