Code Duplication    Length = 25-25 lines in 2 locations

Core/Executor/FileExecutor.php 2 locations

@@ 202-226 (lines=25) @@
199
     * @return true
200
     * @throws \Exception
201
     */
202
    protected function copy($dsl, $context)
203
    {
204
        if (!isset($dsl['from']) || !isset($dsl['to'])) {
205
            throw new \Exception("Can not copy 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 copy 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 copy file to '$to: file already exists");
219
        }
220
221
        if (!copy($fileName, $to)) {
222
            throw new \Exception("Can not copy file '$fileName' to '$to': operation failed");
223
        }
224
225
        return true;
226
    }
227
228
    /**
229
     * @param array $dsl
@@ 234-258 (lines=25) @@
231
     * @return true
232
     * @throws \Exception
233
     */
234
    protected function move($dsl, $context)
235
    {
236
        if (!isset($dsl['from']) || !isset($dsl['to'])) {
237
            throw new \Exception("Can not move file: from or to missing");
238
        }
239
240
        $fileName = $this->referenceResolver->resolveReference($dsl['from']);
241
        if (!file_exists($fileName)) {
242
            throw new \Exception("Can not move file '$fileName': file missing");
243
        }
244
245
        $this->setReferences($fileName, $dsl);
246
247
        $to = $this->referenceResolver->resolveReference($dsl['to']);
248
        $overwrite = isset($dsl['overwrite']) ? $overwrite = $dsl['overwrite'] : false;
249
        if (!$overwrite && file_exists($to)) {
250
            throw new \Exception("Can not move to '$to': file already exists");
251
        }
252
253
        if (!rename($fileName, $to)) {
254
            throw new \Exception("Can not move file '$fileName': operation failed");
255
        }
256
257
        return true;
258
    }
259
260
    /**
261
     * @param array $dsl