Passed
Pull Request — master (#10)
by
unknown
07:04
created

JsonEditorAsset::init()   A

Complexity

Conditions 5
Paths 9

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 17
ccs 0
cts 14
cp 0
rs 9.6111
cc 5
nc 9
nop 0
crap 30
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
    public function init()
50
    {
51
        if (empty($this->css)) {
52
            if (YII_ENV_DEV) {
53
                $this->css = $this->cssDev;
54
            } else {
55
                $this->css = $this->cssProd;
56
            }
57
        }
58
        if (empty($this->js)) {
59
            if (YII_ENV_DEV) {
60
                $this->js = $this->jsDev;
61
            } else {
62
                $this->js = $this->jsProd;
63
            }
64
        }
65
        parent::init();
66
    }
67
}
68