MediaGridController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 32.56 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 3
lcom 1
cbo 3
dl 14
loc 43
rs 10
c 3
b 0
f 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A index() 7 7 1
A ckIndex() 7 7 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php namespace Modules\Media\Http\Controllers\Admin;
2
3
use Modules\Core\Http\Controllers\Admin\AdminBaseController;
4
use Modules\Media\Image\ThumbnailsManager;
5
use Modules\Media\Repositories\FileRepository;
6
7
class MediaGridController extends AdminBaseController
8
{
9
    /**
10
     * @var FileRepository
11
     */
12
    private $file;
13
    /**
14
     * @var ThumbnailsManager
15
     */
16
    private $thumbnailsManager;
17
18
    public function __construct(FileRepository $file, ThumbnailsManager $thumbnailsManager)
19
    {
20
        parent::__construct();
21
22
        $this->file = $file;
23
        $this->thumbnailsManager = $thumbnailsManager;
24
    }
25
26
    /**
27
     * A grid view for the upload button
28
     * @return \Illuminate\View\View
29
     */
30 View Code Duplication
    public function index()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
31
    {
32
        $files = $this->file->all();
33
        $thumbnails = $this->thumbnailsManager->all();
34
35
        return view('media::admin.grid.general', compact('files', 'thumbnails'));
0 ignored issues
show
Bug Compatibility introduced by
The expression view('media::admin.grid....files', 'thumbnails')); of type Illuminate\View\View|Ill...\Contracts\View\Factory adds the type Illuminate\Contracts\View\Factory to the return on line 35 which is incompatible with the return type documented by Modules\Media\Http\Contr...iaGridController::index of type Illuminate\View\View.
Loading history...
36
    }
37
38
    /**
39
     * A grid view of uploaded files used for the wysiwyg editor
40
     * @return \Illuminate\View\View
41
     */
42 View Code Duplication
    public function ckIndex()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
43
    {
44
        $files = $this->file->all();
45
        $thumbnails = $this->thumbnailsManager->all();
46
47
        return view('media::admin.grid.ckeditor', compact('files', 'thumbnails'));
0 ignored issues
show
Bug Compatibility introduced by
The expression view('media::admin.grid....files', 'thumbnails')); of type Illuminate\View\View|Ill...\Contracts\View\Factory adds the type Illuminate\Contracts\View\Factory to the return on line 47 which is incompatible with the return type documented by Modules\Media\Http\Contr...GridController::ckIndex of type Illuminate\View\View.
Loading history...
48
    }
49
}
50