LocalUploadController::getUploadComponent()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 9
rs 10
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
class LocalUploadController extends CommonUploadController
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