Completed
Push — master ( 65befb...50e0e2 )
by Rougin
02:28
created

Refinery::prepareDependencies()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 10
cts 10
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 8
nc 2
nop 0
crap 2
1
<?php
2
3
namespace Rougin\Refinery;
4
5
/**
6
 * Refinery Console
7
 *
8
 * @package Refinery
9
 * @author  Rougin Royce Gutib <[email protected]>
10
 */
11
class Refinery 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 = 'Refinery';
22
23
    /**
24
     * @var string
25
     */
26
    protected static $version = '0.3.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 33
    public static function boot($filename = 'refinery.yml', \Auryn\Injector $injector = null, $directory = null)
37
    {
38 33
        \Rougin\SparkPlug\Instance::create($directory);
39
40 33
        self::$application = parent::boot($filename, $injector, $directory);
41
42 33
        self::prepareDependencies();
43
44 33
        $templates = self::$application->getTemplatePath();
45
46 33
        self::$application->setTemplatePath($templates, null);
47 33
        self::$application->setCommandPath(__DIR__ . DIRECTORY_SEPARATOR . 'Commands');
48 33
        self::$application->setCommandNamespace('Rougin\Refinery\Commands');
49
50 33
        return self::$application;
51
    }
52
53
    /**
54
     * Prepares the dependencies to be used.
55
     *
56
     * @return void
57
     */
58 33
    protected static function prepareDependencies()
59
    {
60 33
        $basePath = BASEPATH;
61
62 33
        require APPPATH . 'config/database.php';
63
64 33
        if (is_dir('vendor/rougin/codeigniter/src/')) {
65 22
            $basePath = 'vendor/rougin/codeigniter/src/';
66 22
        }
67
68 33
        require $basePath . 'helpers/inflector_helper.php';
69
70 33
        $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...
71
72 33
        self::$application->injector->share(new \Rougin\Describe\Describe($driver));
73 33
    }
74
}
75