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

ConsoleConfig::defaultCommand()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
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
}