Completed
Push — master ( ea324c...2e8bb7 )
by Andrey
01:33
created

LocalUploadController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 90 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 18
loc 20
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getUploadComponent() 9 10 2

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
2
3
namespace Itstructure\MFUploader\controllers\upload;
4
5
use yii\base\InvalidConfigException;
6
use Itstructure\MFUploader\interfaces\UploadComponentInterface;
7
8
/**
9
 * Class LocalUploadController
10
 * Upload controller class to upload files in local directory.
11
 *
12
 * @package Itstructure\MFUploader\controllers\upload
13
 *
14
 * @author Andrey Girnik <[email protected]>
15
 */
16 View Code Duplication
class LocalUploadController extends CommonUploadController
0 ignored issues
show
Duplication introduced by
This class 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...
17
{
18
    /**
19
     * Get local upload component.
20
     *
21
     * @throws InvalidConfigException
22
     *
23
     * @return UploadComponentInterface
24
     */
25
    protected function getUploadComponent(): UploadComponentInterface
26
    {
27
        $uploadComponent = $this->module->get('local-upload-component');
28
29
        if (!($uploadComponent instanceof UploadComponentInterface)) {
30
            throw new InvalidConfigException("local-upload-component must be implemented of UploadComponentInterface.");
31
        }
32
33
        return $uploadComponent;
34
    }
35
}
36