Completed
Branch 2.0 (13ec26)
by Anton
05:17
created

CommandsBootloader   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 34
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 5 1
A registerDirectory() 0 14 1
1
<?php
2
/**
3
 * Spiral Framework.
4
 *
5
 * @license   MIT
6
 * @author    Anton Titov (Wolfy-J)
7
 */
8
9
namespace Spiral\Console\Bootloaders;
10
11
use Spiral\Boot\DirectoriesInterface;
12
use Spiral\Config\ModifierInterface;
13
use Spiral\Config\Patches\AppendPatch;
14
use Spiral\Core\Bootloaders\Bootloader;
15
16
/**
17
 * Register framework directories in tokenizer in order to locate default commands.
18
 */
19
class CommandsBootloader extends Bootloader
20
{
21
    const BOOT = true;
22
23
    /**
24
     * @param ModifierInterface    $modifier
25
     * @param DirectoriesInterface $directories
26
     */
27
    public function boot(ModifierInterface $modifier, DirectoriesInterface $directories)
28
    {
29
        $this->registerDirectory($modifier, $directories, 'spiral/console/src');
30
        $this->registerDirectory($modifier, $directories, 'spiral/framework/src');
31
    }
32
33
    /**
34
     * @param ModifierInterface    $modifier
35
     * @param DirectoriesInterface $directories
36
     * @param string               $directory
37
     */
38
    private function registerDirectory(
39
        ModifierInterface $modifier,
40
        DirectoriesInterface $directories,
41
        string $directory
42
    ) {
43
        $modifier->modify(
44
            'tokenizer',
45
            new AppendPatch(
46
                'directories',
47
                null,
48
                $directories->get('vendor') . '/' . $directory
49
            )
50
        );
51
    }
52
}