Code Duplication    Length = 4-5 lines in 4 locations

code/Controller/AssetAdmin.php 4 locations

@@ 284-287 (lines=4) @@
281
        $fileIds = $vars['ids'];
282
        $files = $this->getList()->filter("ID", $fileIds)->toArray();
283
284
        if (!count($files)) {
285
            return (new SS_HTTPResponse(json_encode(['status' => 'error']), 404))
286
                ->addHeader('Content-Type', 'application/json');
287
        }
288
289
        if (!min(array_map(function (File $file) {
290
            return $file->canDelete();
@@ 350-354 (lines=5) @@
347
        $fileClass = File::get_class_for_file_extension(File::get_file_extension($tmpFile['name']));
348
        $file = Injector::inst()->create($fileClass);
349
        $uploadResult = $upload->loadIntoFile($tmpFile, $file, $parentRecord ? $parentRecord->getFilename() : '/');
350
        if(!$uploadResult) {
351
            $result = ['error' => 'unknown'];
352
            return (new SS_HTTPResponse(json_encode($result), 400))
353
                ->addHeader('Content-Type', 'application/json');
354
        }
355
356
        $file->ParentID = $parentRecord->ID;
357
        $file->write();
@@ 679-682 (lines=4) @@
676
        $id = (int) $data['ID'];
677
        $record = $this->getList()->filter('ID', $id)->first();
678
679
        if (!$record) {
680
            return (new SS_HTTPResponse(json_encode(['status' => 'error']), 404))
681
                ->addHeader('Content-Type', 'application/json');
682
        }
683
684
        if (!$record->canEdit()) {
685
            return (new SS_HTTPResponse(json_encode(['status' => 'error']), 401))
@@ 684-687 (lines=4) @@
681
                ->addHeader('Content-Type', 'application/json');
682
        }
683
684
        if (!$record->canEdit()) {
685
            return (new SS_HTTPResponse(json_encode(['status' => 'error']), 401))
686
                ->addHeader('Content-Type', 'application/json');
687
        }
688
689
        $form->saveInto($record);
690
        $record->write();