Code Duplication    Length = 20-21 lines in 2 locations

Core/Matcher/ContentMatcher.php 2 locations

@@ 225-245 (lines=21) @@
222
     * @param string[] $contentTypeIdentifiers
223
     * @return Content[]
224
     */
225
    protected function findContentsByContentTypeIdentifiers(array $contentTypeIdentifiers)
226
    {
227
        $query = new Query();
228
        $query->limit = PHP_INT_MAX;
229
        $query->filter = new Query\Criterion\ContentTypeIdentifier($contentTypeIdentifiers);
230
        // sort objects by depth, lower to higher, so that deleting them has less chances of failure
231
        // NB: we only do this in eZP versions that allow depth sorting on content queries
232
        if (class_exists('eZ\Publish\API\Repository\Values\Content\Query\SortClause\LocationDepth')) {
233
            $query->sortClauses = array(new Query\SortClause\LocationDepth(Query::SORT_DESC));
234
        }
235
236
        $results = $this->repository->getSearchService()->findContent($query);
237
238
        $contents = [];
239
        foreach ($results->searchHits as $result) {
240
            // make sure we return every object only once
241
            $contents[$result->valueObject->contentInfo->id] = $result->valueObject;
242
        }
243
244
        return $contents;
245
    }
246
247
    /**
248
     * @param int[] $contentTypeIds
@@ 251-270 (lines=20) @@
248
     * @param int[] $contentTypeIds
249
     * @return Content[]
250
     */
251
    protected function findContentsByContentTypeIds(array $contentTypeIds)
252
    {
253
        $query = new Query();
254
        $query->limit = PHP_INT_MAX;
255
        $query->filter = new Query\Criterion\ContentTypeId($contentTypeIds);
256
        // sort objects by depth, lower to higher, so that deleting them has less chances of failure
257
        // NB: we only do this in eZP versions that allow depth sorting on content queries
258
        if (class_exists('eZ\Publish\API\Repository\Values\Content\Query\SortClause\LocationDepth')) {
259
            $query->sortClauses = array(new Query\SortClause\LocationDepth(Query::SORT_DESC));
260
        }
261
        $results = $this->repository->getSearchService()->findContent($query);
262
263
        $contents = [];
264
        foreach ($results->searchHits as $result) {
265
            // make sure we return every object only once
266
            $contents[$result->valueObject->contentInfo->id] = $result->valueObject;
267
        }
268
269
        return $contents;
270
    }
271
}
272