Completed
Push — master ( 03d8b8...64d4be )
by Denis
05:05
created

LessFile::load()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 14
rs 9.4285
cc 2
eloc 9
nc 2
nop 1
1
<?php
2
/**
3
 * JBZoo Assets
4
 *
5
 * This file is part of the JBZoo CCK package.
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 *
9
 * @package   Assets
10
 * @license   MIT
11
 * @copyright Copyright (C) JBZoo.com,  All rights reserved.
12
 * @link      https://github.com/JBZoo/Assets
13
 * @author    Sergey Kalistratov <[email protected]>
14
 */
15
16
namespace JBZoo\Assets\Asset;
17
18
use JBZoo\Less\Less;
19
20
/**
21
 * Class LessFile
22
 * @package JBZoo\Assets\Asset
23
 */
24
class LessFile extends File
25
{
26
    protected $_type = Asset::TYPE_LESS_FILE;
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function load(array $filters = [])
32
    {
33
        $result   = parent::load($filters);
34
        $compiled = null;
35
36
        if ($result[1]) {
37
            $options  = $this->_manager->getParams();
38
            $root     = $this->_manager->getPath()->getRoot();
39
            $less     = new Less($options->get('less'));
40
            $compiled = $less->compile($result[1], $root);
0 ignored issues
show
Bug introduced by SmetDenis
It seems like $result[1] can also be of type array or null; however, JBZoo\Less\Less::compile() does only seem to accept string, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
41
        }
42
43
        return [Asset::TYPE_CSS_FILE, $compiled];
44
    }
45
}
46