Code Duplication    Length = 25-25 lines in 2 locations

Core/Executor/FileExecutor.php 2 locations

@@ 170-194 (lines=25) @@
167
     * @return true
168
     * @throws \Exception
169
     */
170
    protected function copy($dsl, $context)
171
    {
172
        if (!isset($dsl['from']) || !isset($dsl['to'])) {
173
            throw new \Exception("Can not copy file: from or to missing");
174
        }
175
176
        $fileName = $this->referenceResolver->resolveReference($dsl['from']);
177
        if (!file_exists($fileName)) {
178
            throw new \Exception("Can not copy file '$fileName': file missing");
179
        }
180
181
        $this->setReferences($fileName, $dsl);
182
183
        $to = $this->referenceResolver->resolveReference($dsl['to']);
184
        $overwrite = isset($dsl['overwrite']) ? $overwrite = $dsl['overwrite'] : false;
185
        if (!$overwrite && file_exists($to)) {
186
            throw new \Exception("Can not copy file to '$to: file already exists");
187
        }
188
189
        if (!copy($fileName, $to)) {
190
            throw new \Exception("Can not copy file '$fileName' to '$to': operation failed");
191
        }
192
193
        return true;
194
    }
195
196
    /**
197
     * @param array $dsl
@@ 202-226 (lines=25) @@
199
     * @return true
200
     * @throws \Exception
201
     */
202
    protected function move($dsl, $context)
203
    {
204
        if (!isset($dsl['from']) || !isset($dsl['to'])) {
205
            throw new \Exception("Can not move file: from or to missing");
206
        }
207
208
        $fileName = $this->referenceResolver->resolveReference($dsl['from']);
209
        if (!file_exists($fileName)) {
210
            throw new \Exception("Can not move file '$fileName': file missing");
211
        }
212
213
        $this->setReferences($fileName, $dsl);
214
215
        $to = $this->referenceResolver->resolveReference($dsl['to']);
216
        $overwrite = isset($dsl['overwrite']) ? $overwrite = $dsl['overwrite'] : false;
217
        if (!$overwrite && file_exists($to)) {
218
            throw new \Exception("Can not move to '$to': file already exists");
219
        }
220
221
        if (!rename($fileName, $to)) {
222
            throw new \Exception("Can not move file '$fileName': operation failed");
223
        }
224
225
        return true;
226
    }
227
228
    /**
229
     * @param array $dsl