Code Duplication    Length = 8-9 lines in 3 locations

src/CRUDlex/AbstractData.php 3 locations

@@ 329-337 (lines=9) @@
326
     * @return boolean
327
     * true on successful creation
328
     */
329
    public function create(Entity $entity) {
330
        $result = $this->shouldExecuteEvents($entity, 'before', 'create');
331
        if (!$result) {
332
            return false;
333
        }
334
        $result = $this->doCreate($entity);
335
        $this->shouldExecuteEvents($entity, 'after', 'create');
336
        return $result;
337
    }
338
339
    /**
340
     * Updates an existing entry in the datasource having the same id.
@@ 348-355 (lines=8) @@
345
     * @return boolean
346
     * true on successful update
347
     */
348
    public function update(Entity $entity) {
349
        if (!$this->shouldExecuteEvents($entity, 'before', 'update')) {
350
            return false;
351
        }
352
        $result = $this->doUpdate($entity);
353
        $this->shouldExecuteEvents($entity, 'after', 'update');
354
        return $result;
355
    }
356
357
    /**
358
     * Deletes an entry from the datasource.
@@ 523-531 (lines=9) @@
520
     * @return boolean
521
     * true on successful deletion
522
     */
523
    public function deleteFile(Entity $entity, $entityName, $field) {
524
        $result = $this->shouldExecuteEvents($entity, 'before', 'deleteFile');
525
        if (!$result) {
526
            return false;
527
        }
528
        $this->fileProcessor->deleteFile($entity, $entityName, $field);
529
        $this->shouldExecuteEvents($entity, 'after', 'deleteFile');
530
        return true;
531
    }
532
533
    /**
534
     * Deletes all files of an existing entity.