Code Duplication    Length = 12-12 lines in 3 locations

src/CRUDlex/AbstractData.php 3 locations

@@ 333-344 (lines=12) @@
330
     * @param string $entityName
331
     * the name of the entity as this class here is not aware of it
332
     */
333
    public function createFiles(Request $request, Entity $entity, $entityName) {
334
        $result = $this->shouldExecuteEvents($entity, 'before', 'createFiles');
335
        if (!$result) {
336
            return false;
337
        }
338
        $fileProcessor = $this->fileProcessor;
339
        $this->performOnFiles($entity, $entityName, function($entity, $entityName, $field) use ($fileProcessor, $request) {
340
            $fileProcessor->createFile($request, $entity, $entityName, $field);
341
        });
342
        $this->shouldExecuteEvents($entity, 'after', 'createFiles');
343
        return true;
344
    }
345
346
    /**
347
     * Updates the uploaded files of an updated entity.
@@ 359-370 (lines=12) @@
356
     * @return boolean
357
     * true on successful update
358
     */
359
    public function updateFiles(Request $request, Entity $entity, $entityName) {
360
        $result = $this->shouldExecuteEvents($entity, 'before', 'updateFiles');
361
        if (!$result) {
362
            return false;
363
        }
364
        $fileProcessor = $this->fileProcessor;
365
        $this->performOnFiles($entity, $entityName, function($entity, $entityName, $field) use ($fileProcessor, $request) {
366
            $fileProcessor->updateFile($request, $entity, $entityName, $field);
367
        });
368
        $this->shouldExecuteEvents($entity, 'after', 'updateFiles');
369
        return true;
370
    }
371
372
    /**
373
     * Deletes a specific file from an existing entity.
@@ 406-417 (lines=12) @@
403
     * @return boolean
404
     * true on successful deletion
405
     */
406
    public function deleteFiles(Entity $entity, $entityName) {
407
        $result = $this->shouldExecuteEvents($entity, 'before', 'deleteFiles');
408
        if (!$result) {
409
            return false;
410
        }
411
        $fileProcessor = $this->fileProcessor;
412
        $this->performOnFiles($entity, $entityName, function($entity, $entityName, $field) use ($fileProcessor) {
413
            $fileProcessor->deleteFile($entity, $entityName, $field);
414
        });
415
        $this->shouldExecuteEvents($entity, 'after', 'deleteFiles');
416
        return true;
417
    }
418
419
    /**
420
     * Renders (outputs) a file of an entity. This includes setting headers