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

BootstrapAsset   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 14 2
1
<?php
2
3
namespace App\Assets;
4
5
use Micro\Mvc\Views\IView;
6
use Micro\Web\Asset;
7
8
/**
9
 * Class BootstrapAsset
10
 * @package App\Assets
11
 */
12
class BootstrapAsset extends Asset
13
{
14
    public static $name = 'Bootstrap';
15
    public static $version = '3.3.6';
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[] = '/js/bootstrap.js';
25
            $this->css[] = '/css/bootstrap.css';
26
        } else {
27
            $this->js[] = '/js/bootstrap.min.js';
28
            $this->css[] = '/css/bootstrap.min.css';
29
        }
30
31
        $this->sourcePath = $view->container->kernel->getAppDir() . '/../vendor/twbs/bootstrap/dist';
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...
32
33
        parent::__construct($view);
34
    }
35
}
36