Code Duplication    Length = 4-5 lines in 4 locations

code/Controller/AssetAdmin.php 4 locations

@@ 289-292 (lines=4) @@
286
        $fileIds = $vars['ids'];
287
        $files = $this->getList()->filter("ID", $fileIds)->toArray();
288
289
        if (!count($files)) {
290
            return (new HTTPResponse(json_encode(['status' => 'error']), 404))
291
                ->addHeader('Content-Type', 'application/json');
292
        }
293
294
        if (!min(array_map(function (File $file) {
295
            return $file->canDelete();
@@ 348-351 (lines=4) @@
345
        $file = Injector::inst()->create($fileClass);
346
347
        // check canCreate permissions
348
        if (!$file->canCreate(null, $data)) {
349
            return (new HTTPResponse(json_encode(['status' => 'error']), 403))
350
                ->addHeader('Content-Type', 'application/json');
351
        }
352
353
        $uploadResult = $upload->loadIntoFile($tmpFile, $file, $parentRecord ? $parentRecord->getFilename() : '/');
354
        if (!$uploadResult) {
@@ 354-358 (lines=5) @@
351
        }
352
353
        $uploadResult = $upload->loadIntoFile($tmpFile, $file, $parentRecord ? $parentRecord->getFilename() : '/');
354
        if (!$uploadResult) {
355
            $result = ['error' => 'unknown'];
356
            return (new HTTPResponse(json_encode($result), 400))
357
                ->addHeader('Content-Type', 'application/json');
358
        }
359
360
        $file->ParentID = $parentRecord ? $parentRecord->ID : 0;
361
        $file->write();
@@ 685-688 (lines=4) @@
682
        /** @var File $record */
683
        $record = $this->getList()->filter('ID', $id)->first();
684
685
        if (!$record) {
686
            return (new HTTPResponse(json_encode(['status' => 'error']), 404))
687
                ->addHeader('Content-Type', 'application/json');
688
        }
689
690
        if (!$record->canEdit() || ($doPublish && !$record->canPublish())) {
691
            return (new HTTPResponse(json_encode(['status' => 'error']), 401))