Code Duplication    Length = 30-30 lines in 2 locations

Core/Executor/ContentManager.php 1 location

@@ 317-346 (lines=30) @@
314
     * @return ContentCollection
315
     * @throws \Exception
316
     */
317
    protected function matchContents($action)
318
    {
319
        if (!isset($this->dsl['object_id']) && !isset($this->dsl['remote_id']) && !isset($this->dsl['match'])) {
320
            throw new \Exception("The ID or remote ID of an object or a Match Condition is required to $action a new location.");
321
        }
322
323
        // Backwards compat
324
        if (!isset($this->dsl['match'])) {
325
            if (isset($this->dsl['object_id'])) {
326
                $this->dsl['match'] = array('content_id' => $this->dsl['object_id']);
327
            } elseif (isset($this->dsl['remote_id'])) {
328
                $this->dsl['match'] = array('content_remote_id' => $this->dsl['remote_id']);
329
            }
330
        }
331
332
        $match = $this->dsl['match'];
333
334
        // convert the references passed in the match
335
        foreach ($match as $condition => $values) {
336
            if (is_array($values)) {
337
                foreach ($values as $position => $value) {
338
                    $match[$condition][$position] = $this->referenceResolver->resolveReference($value);
339
                }
340
            } else {
341
                $match[$condition] = $this->referenceResolver->resolveReference($values);
342
            }
343
        }
344
345
        return $this->contentMatcher->match($match);
346
    }
347
348
    /**
349
     * Helper function to set the fields of a ContentCreateStruct based on the DSL attribute settings.

Core/Executor/LocationManager.php 1 location

@@ 261-290 (lines=30) @@
258
     * @return ContentCollection
259
     * @throws \Exception
260
     */
261
    protected function matchContents($action)
262
    {
263
        if (!isset($this->dsl['object_id']) && !isset($this->dsl['remote_id']) && !isset($this->dsl['match'])) {
264
            throw new \Exception("The ID or remote ID of an object or a Match Condition is required to $action a new location.");
265
        }
266
267
        // Backwards compat
268
        if (!isset($this->dsl['match'])) {
269
            if (isset($this->dsl['object_id'])) {
270
                $this->dsl['match'] = array('content_id' => $this->dsl['object_id']);
271
            } elseif (isset($this->dsl['remote_id'])) {
272
                $this->dsl['match'] = array('content_remote_id' => $this->dsl['remote_id']);
273
            }
274
        }
275
276
        $match = $this->dsl['match'];
277
278
        // convert the references passed in the match
279
        foreach ($match as $condition => $values) {
280
            if (is_array($values)) {
281
                foreach ($values as $position => $value) {
282
                    $match[$condition][$position] = $this->referenceResolver->resolveReference($value);
283
                }
284
            } else {
285
                $match[$condition] = $this->referenceResolver->resolveReference($values);
286
            }
287
        }
288
289
        return $this->contentMatcher->matchContent($match);
290
    }
291
292
    /**
293
     * @param $newValue