Completed
Push — master ( d6bb8e...21b718 )
by Oleg
05:17
created

JqueryAsset::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 12
rs 9.4285
cc 2
eloc 7
nc 2
nop 1
1
<?php
2
3
namespace App\Assets;
4
5
use Micro\Mvc\Views\IView;
6
use Micro\Web\Asset;
7
8
/**
9
 * Class JqueryAsset
10
 * @package App\Assets
11
 */
12
class JqueryAsset extends Asset
13
{
14
    public static $name = 'JQuery';
15
    public static $version = '2.2.1';
16
17
    /**
18
     * @param IView $view
19
     * @throws \Micro\Base\Exception
20
     */
21
    public function __construct(IView $view)
22
    {
23
        if ($view->container->kernel->isDebug()) {
0 ignored issues
show
Bug introduced by
Accessing container on the interface Micro\Mvc\Views\IView suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
24
            $this->js[] = '/jquery.js';
25
        } else {
26
            $this->js[] = '/jquery.min.js';
27
        }
28
29
        $this->sourcePath = $view->container->kernel->getAppDir() . '/../vendor/components/jquery';
0 ignored issues
show
Bug introduced by
Accessing container on the interface Micro\Mvc\Views\IView suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
30
31
        parent::__construct($view);
32
    }
33
}
34