Completed
Pull Request — master (#17)
by Rougin
11:45
created

Combustor   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 4
c 3
b 0
f 0
lcom 1
cbo 7
dl 0
loc 76
ccs 23
cts 23
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 14 1
A prepareDependencies() 0 16 2
A prepareTemplates() 0 8 1
1
<?php
2
3
namespace Rougin\Combustor;
4
5
/**
6
 * Combustor Console
7
 *
8
 * @package Combustor
9
 * @author  Rougin Royce Gutib <[email protected]>
10
 */
11
class Combustor extends \Rougin\Blueprint\Console
12
{
13
    /**
14
     * @var \Rougin\Blueprint\Blueprint
15
     */
16
    protected static $application;
17
18
    /**
19
     * @var string
20
     */
21
    protected static $name = 'Combustor';
22
23
    /**
24
     * @var string
25
     */
26
    protected static $version = '2.0.0';
27
28
    /**
29
     * Prepares the console application.
30
     *
31
     * @param  string               $filename
32
     * @param  \Auryn\Injector|null $injector
33
     * @param  string|null          $directory
34
     * @return \Rougin\Blueprint\Blueprint
35
     */
36 3
    public static function boot($filename = 'combustor.yml', \Auryn\Injector $injector = null, $directory = null)
37
    {
38 3
        \Rougin\SparkPlug\Instance::create($directory);
39
40 3
        self::$application = parent::boot($filename, $injector, $directory);
41
42 3
        self::prepareDependencies();
43 3
        self::prepareTemplates();
44
45 3
        self::$application->setCommandPath(__DIR__ . DIRECTORY_SEPARATOR . 'Commands');
46 3
        self::$application->setCommandNamespace('Rougin\Combustor\Commands');
47
48 3
        return self::$application;
49
    }
50
51
    /**
52
     * Prepares the dependencies to be used.
53
     *
54
     * @return void
55
     */
56 3
    protected static function prepareDependencies()
57
    {
58 3
        $basePath = BASEPATH;
59
60 3
        require APPPATH . 'config/database.php';
61
62 3
        if (is_dir('vendor/rougin/codeigniter/src/')) {
63 2
            $basePath = 'vendor/rougin/codeigniter/src/';
64 2
        }
65
66 3
        require $basePath . 'helpers/inflector_helper.php';
67
68 3
        $driver = new \Rougin\Describe\Driver\CodeIgniterDriver($db[$active_group]);
0 ignored issues
show
Bug introduced by
The variable $db does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
Bug introduced by
The variable $active_group does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
69
70 3
        self::$application->injector->share(new \Rougin\Describe\Describe($driver));
71 3
    }
72
73
    /**
74
     * Prepares the templates to be used.
75
     *
76
     * @return void
77
     */
78 3
    protected static function prepareTemplates()
79
    {
80 3
        $extensions = [ new \Rougin\Combustor\Common\InflectorExtension ];
81
82 3
        $template = self::$application->getTemplatePath();
83
84 3
        self::$application->setTemplatePath($template, null, $extensions);
85 3
    }
86
}
87