JsonEditorAsset::init()   A
last analyzed

Complexity

Conditions 5
Paths 9

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 17
ccs 14
cts 14
cp 1
rs 9.6111
cc 5
nc 9
nop 0
crap 5
1
<?php
2
3
namespace kdn\yii2\assets;
4
5
use yii\web\AssetBundle;
6
7
/**
8
 * Class JsonEditorAsset.
9
 * @package kdn\yii2\assets
10
 */
11
abstract class JsonEditorAsset extends AssetBundle
12
{
13
    /**
14
     * @var array list of CSS files which this bundle will use for development environment
15
     * @see $css
16
     */
17
    public $cssDev = [
18
        'jsoneditor.css',
19
    ];
20
21
    /**
22
     * @var array list of CSS files which this bundle will use for production environment
23
     * @see $css
24
     */
25
    public $cssProd = [
26
        'jsoneditor.min.css',
27
    ];
28
29
    /**
30
     * @var array list of JavaScript files which this bundle will use for development environment
31
     * @see $js
32
     */
33
    public $jsDev;
34
35
    /**
36
     * @var array list of JavaScript files which this bundle will use for production environment
37
     * @see $js
38
     */
39
    public $jsProd;
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public $sourcePath = '@npm/jsoneditor/dist';
45
46
    /**
47
     * {@inheritdoc}
48
     */
49 2
    public function init()
50
    {
51 2
        if (empty($this->css)) {
52 2
            if (YII_ENV_DEV) {
53 1
                $this->css = $this->cssDev;
54 1
            } else {
55 1
                $this->css = $this->cssProd;
56
            }
57 2
        }
58 2
        if (empty($this->js)) {
59 2
            if (YII_ENV_DEV) {
60 1
                $this->js = $this->jsDev;
61 1
            } else {
62 1
                $this->js = $this->jsProd;
63
            }
64 2
        }
65 2
        parent::init();
66 2
    }
67
}
68