Code Duplication    Length = 25-25 lines in 2 locations

Core/Executor/FileExecutor.php 2 locations

@@ 220-244 (lines=25) @@
217
     * @return true
218
     * @throws \Exception
219
     */
220
    protected function copy($dsl, $context)
221
    {
222
        if (!isset($dsl['from']) || !isset($dsl['to'])) {
223
            throw new \Exception("Can not copy file: from or to missing");
224
        }
225
226
        $fileName = $this->referenceResolver->resolveReference($dsl['from']);
227
        if (!file_exists($fileName)) {
228
            throw new \Exception("Can not copy file '$fileName': file missing");
229
        }
230
231
        $this->setReferences($fileName, $dsl);
232
233
        $to = $this->referenceResolver->resolveReference($dsl['to']);
234
        $overwrite = isset($dsl['overwrite']) ? $overwrite = $dsl['overwrite'] : false;
235
        if (!$overwrite && file_exists($to)) {
236
            throw new \Exception("Can not copy file to '$to: file already exists");
237
        }
238
239
        if (!copy($fileName, $to)) {
240
            throw new \Exception("Can not copy file '$fileName' to '$to': operation failed");
241
        }
242
243
        return true;
244
    }
245
246
    /**
247
     * @param array $dsl
@@ 252-276 (lines=25) @@
249
     * @return true
250
     * @throws \Exception
251
     */
252
    protected function move($dsl, $context)
253
    {
254
        if (!isset($dsl['from']) || !isset($dsl['to'])) {
255
            throw new \Exception("Can not move file: from or to missing");
256
        }
257
258
        $fileName = $this->referenceResolver->resolveReference($dsl['from']);
259
        if (!file_exists($fileName)) {
260
            throw new \Exception("Can not move file '$fileName': file missing");
261
        }
262
263
        $this->setReferences($fileName, $dsl);
264
265
        $to = $this->referenceResolver->resolveReference($dsl['to']);
266
        $overwrite = isset($dsl['overwrite']) ? $overwrite = $dsl['overwrite'] : false;
267
        if (!$overwrite && file_exists($to)) {
268
            throw new \Exception("Can not move to '$to': file already exists");
269
        }
270
271
        if (!rename($fileName, $to)) {
272
            throw new \Exception("Can not move file '$fileName': operation failed");
273
        }
274
275
        return true;
276
    }
277
278
    /**
279
     * @param array $dsl