Completed
Branch 09branch (0a5c88)
by Anton
05:50
created

ConsoleConfig   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 75
rs 10
c 0
b 0
f 0
wmc 7
lcom 1
cbo 1

5 Methods

Rating   Name   Duplication   Size   Complexity  
A defaultCommand() 0 4 1
A locateCommands() 0 9 2
A userCommands() 0 9 2
A configureSequence() 0 4 1
A updateSequence() 0 4 1
1
<?php
2
/**
3
 * Spiral Framework.
4
 *
5
 * @license MIT
6
 * @author  Anton Titov (Wolfy-J)
7
 */
8
9
namespace Spiral\Console\Configs;
10
11
use Spiral\Core\InjectableConfig;
12
13
/**
14
 * Console component configuration.
15
 */
16
class ConsoleConfig extends InjectableConfig
17
{
18
    /**
19
     * Configuration section.
20
     */
21
    const CONFIG = 'console';
22
23
    /**
24
     * @var array
25
     */
26
    protected $config = [
27
        'locateCommands'    => true,
28
        'commands'          => [],
29
        'updateSequence'    => [],
30
        'configureSequence' => []
31
    ];
32
33
    /**
34
     * @return string
35
     */
36
    public function defaultCommand(): string
37
    {
38
        return $this->config['defaultCommand'] ??'list';
39
    }
40
41
    /**
42
     * Indication that ConsoleDispatcher must locate commands.
43
     *
44
     * @return bool
45
     */
46
    public function locateCommands(): bool
47
    {
48
        if (!array_key_exists('locateCommands', $this->config)) {
49
            //Legacy config support
50
            return true;
51
        }
52
53
        return $this->config['locateCommands'];
54
    }
55
56
    /**
57
     * User defined set of commands (to be used when auto-location is off).
58
     *
59
     * @return array
60
     */
61
    public function userCommands(): array
62
    {
63
        if (!array_key_exists('commands', $this->config)) {
64
            //Legacy config support
65
            return [];
66
        }
67
68
        return $this->config['commands'];
69
    }
70
71
    /**
72
     * Set of commands to be executed in "spiral:configure" command.
73
     *
74
     * @return array
75
     */
76
    public function configureSequence(): array
77
    {
78
        return $this->config['configureSequence'];
79
    }
80
81
    /**
82
     * Set of commands to be executed in "spiral:update" command.
83
     *
84
     * @return array
85
     */
86
    public function updateSequence(): array
87
    {
88
        return $this->config['updateSequence'];
89
    }
90
}