Test Failed
Push — master ( eaa667...0d9623 )
by Evgenii
38:52
created

ImportForm::import()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
4
namespace floor12\backup\models;
5
6
7
use floor12\backup\logic\BackupImporter;
8
use yii\base\Model;
9
use yii\web\UploadedFile;
10
11
class ImportForm extends Model
12
{
13
    /** @var integer */
14
    public $config_id;
15
    /** @var UploadedFile */
16
    public $file;
17
18
    /**
19
     * @return array
20
     */
21
    public function rules(): array
22
    {
23
        return [
24
            [['config_id', 'file'], 'required'],
25
            ['config_id', 'integer'],
26
            ['file', 'file', 'extensions' => ['dump', 'zip'], 'maxFiles' => 1]
27
        ];
28
    }
29
30
    /**
31
     * @return bool
32
     * @throws \floor12\backup\Exceptions\ConfigurationNotFoundException
33
     * @throws \floor12\backup\Exceptions\FileNotFoundException
34
     * @throws \floor12\backup\Exceptions\ModuleNotConfiguredException
35
     */
36
    public function import(): bool
37
    {
38
        $importer = new BackupImporter($this->config_id, $this->file->tempName, $this->file->name);
39
        return $importer->import();
40
    }
41
}
42