AdminAsset   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
c 2
b 0
f 0
lcom 1
cbo 3
dl 0
loc 36
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A init() 0 20 3
1
<?php
2
/**
3
 * @link http://www.yiiframework.com/
4
 *
5
 * @copyright Copyright (c) 2008 Yii Software LLC
6
 * @license http://www.yiiframework.com/license/
7
 */
8
namespace app\modules\backend\assets;
9
10
use yii\helpers\FileHelper;
11
use yii\web\AssetBundle;
12
13
/**
14
 * Configuration for `backend` client script files.
15
 *
16
 * @since 4.0
17
 */
18
class AdminAsset extends AssetBundle
19
{
20
    public $sourcePath = '@app/modules/backend/assets/web';
21
22
    public $css = [
23
        'less/site.less',
24
    ];
25
    public $js = [
26
    ];
27
    public $depends = [
28
        'yii\web\YiiAsset',
29
        'yii\bootstrap\BootstrapAsset',
30
        'dmstr\web\AdminLteAsset',
31
    ];
32
33
    public function init()
34
    {
35
        parent::init();
36
        // we recompile the less files from 'yii\bootstrap\BootstrapAsset' and include the css in app.css
37
        // therefore we set bundle to false
38
        \Yii::$app->getAssetManager()->bundles['yii\bootstrap\BootstrapAsset'] = false;
39
40
        // /!\ CSS/LESS development only setting /!\
41
        // Touch the asset folder with the highest mtime of all contained files
42
        // This will create a new folder in web/assets for every change and request
43
        // made to the app assets.
44
        if (getenv('APP_ASSET_FORCE_PUBLISH')) {
45
            $files = FileHelper::findFiles(\Yii::getAlias($this->sourcePath));
0 ignored issues
show
Bug introduced by
It seems like \Yii::getAlias($this->sourcePath) targeting yii\BaseYii::getAlias() can also be of type boolean; however, yii\helpers\BaseFileHelper::findFiles() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
46
            $mtimes = [];
47
            foreach ($files as $file) {
48
                $mtimes[] = filemtime($file);
49
            }
50
            touch(\Yii::getAlias($this->sourcePath), max($mtimes));
51
        }
52
    }
53
}
54