Passed
Push — master ( 5a9e1e...a9a8cf )
by Alexey
03:09
created

UploadAvatarForm::run()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 3
c 1
b 0
f 1
dl 0
loc 5
rs 10
cc 2
nc 2
nop 0
1
<?php
2
3
namespace modules\users\widgets;
4
5
use modules\users\models\UploadForm;
6
use yii\base\InvalidArgumentException;
7
use yii\base\Widget;
8
9
/**
10
 * Class AvatarFormWidget
11
 * @package modules\users\widgets
12
 */
13
class UploadAvatarForm extends Widget
14
{
15
    /**
16
     * On/Off widget
17
     * @var bool
18
     */
19
    public $status = true;
20
    /**
21
     * @var UploadForm
22
     */
23
    public $model;
24
25
    /**
26
     * @inheritDoc
27
     */
28
    public function init()
29
    {
30
        parent::init();
31
        if (($this->status === true) && !($this->model instanceof UploadForm)) {
0 ignored issues
show
introduced by
$this->model is always a sub-type of modules\users\models\UploadForm.
Loading history...
32
            throw new InvalidArgumentException('The model is not an instance of class: ' . UploadForm::class);
33
        }
34
    }
35
36
    /**
37
     * @return string|void
38
     */
39
    public function run()
40
    {
41
        if ($this->status === true) {
42
            echo $this->render('uploadAvatarForm', [
43
                'model' => $this->model
44
            ]);
45
        }
46
    }
47
}
48