SubscribeFormWidget   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 10
c 0
b 0
f 0
dl 0
loc 39
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 4 2
A registerResource() 0 4 1
A run() 0 5 2
1
<?php
2
3
namespace dominus77\maintenance\widgets\subscribe;
4
5
use yii\base\Widget;
6
use dominus77\maintenance\models\SubscribeForm as SubscribeFormModel;
7
use dominus77\maintenance\widgets\subscribe\assets\SubscribeFormAsset;
8
9
/**
10
 * Class SubscribeFormWidget
11
 * @package dominus77\maintenance\widgets\subscribe
12
 */
13
class SubscribeFormWidget extends Widget
14
{
15
    /**
16
     * @var bool
17
     */
18
    public $status = true;
19
20
    /**
21
     * @var SubscribeFormModel
22
     */
23
    public $model;
24
25
    /**
26
     * @inheritDoc
27
     */
28
    public function init()
29
    {
30
        parent::init();
31
        $this->model = $this->model ?: new SubscribeFormModel();
32
    }
33
34
    /**
35
     * @return string|void
36
     */
37
    public function run()
38
    {
39
        if ($this->status === true) {
40
            $this->registerResource();
41
            echo $this->render('subscribe-form', ['model' => $this->model]);
42
        }
43
    }
44
45
    /**
46
     * Register resource
47
     */
48
    protected function registerResource()
49
    {
50
        $view = $this->getView();
51
        SubscribeFormAsset::register($view);
52
    }
53
}
54