Code Duplication    Length = 34-34 lines in 2 locations

Core/Executor/ContentManager.php 1 location

@@ 32-65 (lines=34) @@
29
     * @return ContentCollection
30
     * @throws \Exception
31
     */
32
    protected function matchContents($action)
33
    {
34
        if (!isset($this->dsl['object_id']) && !isset($this->dsl['remote_id']) && !isset($this->dsl['match'])) {
35
            throw new \Exception("The ID or remote ID of an object or a Match Condition is required to $action a new location.");
36
        }
37
38
        // Backwards compat
39
        if (!isset($this->dsl['match'])) {
40
            if (isset($this->dsl['object_id'])) {
41
                $this->dsl['match'] = array('content_id' => $this->dsl['object_id']);
42
            } elseif (isset($this->dsl['remote_id'])) {
43
                $this->dsl['match'] = array('content_remote_id' => $this->dsl['remote_id']);
44
            }
45
        }
46
47
        $match = $this->dsl['match'];
48
49
        // convert the references passed in the match
50
        foreach ($match as $condition => $values) {
51
            if (is_array($values)) {
52
                foreach ($values as $position => $value) {
53
                    if ($this->referenceResolver->isReference($value)) {
54
                        $match[$condition][$position] = $this->referenceResolver->getReferenceValue($value);
55
                    }
56
                }
57
            } else {
58
                if ($this->referenceResolver->isReference($values)) {
59
                    $match[$condition] = $this->referenceResolver->getReferenceValue($values);
60
                }
61
            }
62
        }
63
64
        return $this->contentMatcher->matchContent($match);
65
    }
66
67
    /**
68
     * Handle the content create migration action type

Core/Executor/LocationManager.php 1 location

@@ 27-60 (lines=34) @@
24
     * @return ContentCollection
25
     * @throws \Exception
26
     */
27
    protected function matchContents($action)
28
    {
29
        if (!isset($this->dsl['object_id']) && !isset($this->dsl['remote_id']) && !isset($this->dsl['match'])) {
30
            throw new \Exception("The ID or remote ID of an object or a Match Condition is required to $action a new location.");
31
        }
32
33
        // Backwards compat
34
        if (!isset($this->dsl['match'])) {
35
            if (isset($this->dsl['object_id'])) {
36
                $this->dsl['match'] = array('content_id' => $this->dsl['object_id']);
37
            } elseif (isset($this->dsl['remote_id'])) {
38
                $this->dsl['match'] = array('content_remote_id' => $this->dsl['remote_id']);
39
            }
40
        }
41
42
        $match = $this->dsl['match'];
43
44
        // convert the references passed in the match
45
        foreach ($match as $condition => $values) {
46
            if (is_array($values)) {
47
                foreach ($values as $position => $value) {
48
                    if ($this->referenceResolver->isReference($value)) {
49
                        $match[$condition][$position] = $this->referenceResolver->getReferenceValue($value);
50
                    }
51
                }
52
            } else {
53
                if ($this->referenceResolver->isReference($values)) {
54
                    $match[$condition] = $this->referenceResolver->getReferenceValue($values);
55
                }
56
            }
57
        }
58
59
        return $this->contentMatcher->matchContent($match);
60
    }
61
62
    /**
63
     * Method to handle the create operation of the migration instructions