Completed
Push — master ( b4d6a5...352f6d )
by Basil
02:42
created

Asset   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 18
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A init() 0 9 2
1
<?php
2
3
namespace luya\web;
4
5
use luya\helpers\Inflector;
6
use ReflectionClass;
7
8
/**
9
 * Asset Bundles.
10
 *
11
 * Since version 1.1, the main differente to the Yii implementation is that {{$sourcePath}} has a default value which points into a `/resources` folder containing
12
 * the name of the assets itself.
13
 * 
14
 * Assuming an `MySuperAsset` asset in `/app` folder will lookup all files under `/app/resources/my-super-asset/...`.
15
 *
16
 * @author Basil Suter <[email protected]>
17
 * @since 1.0.0
18
 */
19
class Asset extends \yii\web\AssetBundle
20
{
21
    /**
22
     * @var string When $sourcePath is null, the Asset object will automatically assign this folder relative to its object.
23
     * @since 1.1.0
24
     */
25
    public $defaultSourcePathFolder = 'resources';
26
27
    public function init()
28
    {
29
        parent::init();
30
31
        if ($this->sourcePath === null) {
32
            $class = new ReflectionClass($this);
33
            $this->sourcePath = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . $this->defaultSourcePathFolder . DIRECTORY_SEPARATOR . Inflector::camel2id($class->getShortName());
34
        }
35
    }
36
}
37