Code Duplication    Length = 34-34 lines in 2 locations

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

Core/Executor/ContentManager.php 1 location

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