Completed
Push — master ( c5eccd...ec8b64 )
by Evgenii
04:45
created

VideoWidget   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
eloc 7
c 1
b 0
f 1
dl 0
loc 16
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 6 2
1
<?php
2
3
4
namespace floor12\files\components;
5
6
7
use floor12\files\models\File;
8
use floor12\files\models\FileType;
9
use yii\base\Widget;
10
use yii\helpers\Html;
11
12
class VideoWidget extends Widget
13
{
14
    /** @var File */
15
    public $model;
16
    /** @var array */
17
    public $options = [];
18
19
    /**
20
     * @return string|null
21
     */
22
    public function run(): ?string
23
    {
24
        if ($this->model->type !== FileType::VIDEO)
25
            return null;
26
        $source = Html::tag('source', null, ['src' => $this->model->getHref(), 'type' => $this->model->content_type]);
27
        return Html::tag('video', $source, $this->options);
28
    }
29
}
30