Completed
Push — 3.0 ( fea5eb...c29f0e )
by Vermeulen
02:17
created

Constants::init()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 9.6666
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace BFW\Core\AppSystems;
4
5
class Constants extends AbstractSystem
6
{
7
    /**
8
     * {@inheritdoc}
9
     * @return null
10
     */
11
    public function __invoke()
12
    {
13
        return null;
14
    }
15
16
    /**
17
     * {@inheritdoc}
18
     * Define all constants
19
     */
20
    public function init()
21
    {
22
        \BFW\Helpers\Constants::create('ROOT_DIR', $this->obtainRootDir());
23
24
        \BFW\Helpers\Constants::create('APP_DIR', ROOT_DIR.'app/');
25
        \BFW\Helpers\Constants::create('SRC_DIR', ROOT_DIR.'src/');
26
        \BFW\Helpers\Constants::create('WEB_DIR', ROOT_DIR.'web/');
27
28
        \BFW\Helpers\Constants::create('CONFIG_DIR', APP_DIR.'config/');
29
        \BFW\Helpers\Constants::create('MODULES_DIR', APP_DIR.'modules/');
30
31
        \BFW\Helpers\Constants::create('CLI_DIR', SRC_DIR.'cli/');
32
        \BFW\Helpers\Constants::create('CTRL_DIR', SRC_DIR.'controllers/');
33
        \BFW\Helpers\Constants::create('MODELES_DIR', SRC_DIR.'modeles/');
34
        \BFW\Helpers\Constants::create('VIEW_DIR', SRC_DIR.'view/');
35
        
36
        $this->initStatus = true;
37
    }
38
    
39
    /**
40
     * Obtain the path of the application root directory
41
     * 
42
     * @return string
43
     */
44
    protected function obtainRootDir()
45
    {
46
        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...
47
            ->getOptions()
48
            ->getValue('rootDir')
49
        ;
50
    }
51
}
52