Code Duplication    Length = 20-20 lines in 2 locations

Core/Matcher/LocationMatcher.php 1 location

@@ 45-64 (lines=20) @@
42
     * @param array $conditions key: condition, value: value: int / string / int[] / string[]
43
     * @return LocationCollection
44
     */
45
    public function matchLocation(array $conditions)
46
    {
47
        $this->validateConditions($conditions);
48
49
        foreach ($conditions as $key => $values) {
50
51
            $query = new LocationQuery();
52
            $query->limit = self::INT_MAX_16BIT;
53
            if (isset($query->performCount)) $query->performCount = false;
54
            $query->filter = $this->getQueryCriterion($key, $values);
55
            $results = $this->repository->getSearchService()->findLocations($query);
56
57
            $locations = [];
58
            foreach ($results->searchHits as $result) {
59
                $locations[$result->valueObject->id] = $result->valueObject;
60
            }
61
62
            return new LocationCollection($locations);
63
        }
64
    }
65
66
    /**
67
     * When matching by key, we accept location Id and remote Id only

Core/Matcher/TrashMatcher.php 1 location

@@ 31-50 (lines=20) @@
28
     * @todo test all supported matching conditions
29
     * @todo support matching by item_id
30
     */
31
    public function matchItem(array $conditions)
32
    {
33
        $this->validateConditions($conditions);
34
35
        foreach ($conditions as $key => $values) {
36
37
            $query = new Query();
38
            $query->limit = self::INT_MAX_16BIT;
39
            if (isset($query->performCount)) $query->performCount = false;
40
            $query->filter = $this->getQueryCriterion($key, $values);
41
            $results = $this->repository->getTrashService()->findTrashItems($query);
42
43
            $items = [];
44
            foreach ($results->searchHits as $result) {
45
                $items[$result->valueObject->id] = $result->valueObject;
46
            }
47
48
            return new TrashedItemCollection($items);
49
        }
50
    }
51
}
52