Code Duplication    Length = 13-13 lines in 3 locations

Core/Executor/FileExecutor.php 3 locations

@@ 112-124 (lines=13) @@
109
            throw new \Exception("Can not save file: name or body or template missing");
110
        }
111
112
        if (is_string($dsl['body'])) {
113
            $contents = $this->resolveReferencesInText($dsl['body']);
114
        } elseif (is_string($dsl['template'])) {
115
            $path = $this->referenceResolver->resolveReference($dsl['template']);
116
            // we use the same logic as for the image/file fields in content: look up file 1st relative to the migration
117
            $template = dirname($context['path']) . '/' . $path;
118
            if (!is_file($template)) {
119
                $template = $path;
120
            }
121
            $contents = $this->resolveReferencesInText(file_get_contents($template));
122
        } else {
123
            throw new \Exception("Can not save file: either body or template tag must be a string");
124
        }
125
126
        $fileName = $this->referenceResolver->resolveReference($dsl['file']);
127
@@ 152-164 (lines=13) @@
149
            throw new \Exception("Can not append to file: name or body or template missing");
150
        }
151
152
        if (is_string($dsl['body'])) {
153
            $contents = $this->resolveReferencesInText($dsl['body']);
154
        } elseif (is_string($dsl['template'])) {
155
            $path = $this->referenceResolver->resolveReference($dsl['template']);
156
            // we use the same logic as for the image/file fields in content: look up file 1st relative to the migration
157
            $template = dirname($context['path']) . '/' . $path;
158
            if (!is_file($template)) {
159
                $template = $path;
160
            }
161
            $contents = $this->resolveReferencesInText(file_get_contents($template));
162
        } else {
163
            throw new \Exception("Can not append to file: either body or template tag must be a string");
164
        }
165
166
        $fileName = $this->referenceResolver->resolveReference($dsl['file']);
167
@@ 187-199 (lines=13) @@
184
            throw new \Exception("Can not prepend to file: name or body or template missing");
185
        }
186
187
        if (is_string($dsl['body'])) {
188
            $contents = $this->resolveReferencesInText($dsl['body']);
189
        } elseif (is_string($dsl['template'])) {
190
            $path = $this->referenceResolver->resolveReference($dsl['template']);
191
            // we use the same logic as for the image/file fields in content: look up file 1st relative to the migration
192
            $template = dirname($context['path']) . '/' . $path;
193
            if (!is_file($template)) {
194
                $template = $path;
195
            }
196
            $contents = $this->resolveReferencesInText(file_get_contents($template));
197
        } else {
198
            throw new \Exception("Can not append to file: either body or template tag must be a string");
199
        }
200
201
        $fileName = $this->referenceResolver->resolveReference($dsl['file']);
202