GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — 3.0 ( fea5eb...c29f0e )
by Vermeulen
02:17
created

ComposerLoader   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 4 1
A getLoader() 0 4 1
A init() 0 10 1
A obtainVendorDir() 0 7 1
A addComposerNamespaces() 0 6 1
1
<?php
2
3
namespace BFW\Core\AppSystems;
4
5
class ComposerLoader extends AbstractSystem
6
{
7
    /**
8
     * @var \Composer\Autoload\ClassLoader|null $loader Composer auto-loader
9
     */
10
    protected $loader;
11
    
12
    /**
13
     * {@inheritdoc}
14
     * 
15
     * @return \Composer\Autoload\ClassLoader|null
16
     */
17
    public function __invoke()
18
    {
19
        return $this->loader;
20
    }
21
    
22
    /**
23
     * Getter accessor to property loader
24
     * 
25
     * @return \Composer\Autoload\ClassLoader|null
26
     */
27
    public function getLoader()
28
    {
29
        return $this->loader;
30
    }
31
    
32
    /**
33
     * {@inheritdoc}
34
     * Define loader property and add all namespaces
35
     */
36
    public function init()
37
    {
38
        $this->loader = require(
39
            $this->obtainVendorDir().'autoload.php'
40
        );
41
        
42
        $this->addComposerNamespaces();
43
        
44
        $this->initStatus = true;
45
    }
46
    
47
    /**
48
     * Return the path to the vendor directory
49
     * 
50
     * @return string
51
     */
52
    protected function obtainVendorDir()
53
    {
54
        return \BFW\Application::getInstance()
0 ignored issues
show
Documentation Bug introduced by
The method getOptions does not exist on object<BFW\Application>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
55
            ->getOptions()
56
            ->getValue('vendorDir')
57
        ;
58
    }
59
60
    /**
61
     * Add namespaces used by a BFW Application to composer
62
     * 
63
     * @return void
64
     */
65
    protected function addComposerNamespaces()
66
    {
67
        $this->loader->addPsr4('Controller\\', CTRL_DIR);
68
        $this->loader->addPsr4('Modules\\', MODULES_DIR);
69
        $this->loader->addPsr4('Modeles\\', MODELES_DIR);
70
    }
71
}
72