Completed
Pull Request — master (#642)
by Greg
03:19
created

Config::isDecorated()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
namespace Robo\Config;
3
4
class Config extends \Consolidation\Config\Config implements GlobalOptionDefaultValuesInterface
0 ignored issues
show
Deprecated Code introduced by
The interface Robo\Config\GlobalOptionDefaultValuesInterface has been deprecated with message: Use robo.yml instead robo.yml: options: simulated: false progress-delay: 2 etc.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
5
{
6
    const PROGRESS_BAR_AUTO_DISPLAY_INTERVAL = 'options.progress-delay';
7
    const DEFAULT_PROGRESS_DELAY = 2;
8
    const SIMULATE = 'options.simulate';
9
10
    // Read-only configuration properties; changing these has no effect.
11
    const INTERACTIVE = 'options.interactive';
12
    const DECORATED = 'options.decorated';
13
14
    /**
15
     * Create a new configuration object, and initialize it with
16
     * the provided nested array containing configuration data.
17
     */
18
    public function __construct(array $data = null)
19
    {
20
        parent::__construct($data);
21
        $this->defaults = $this->getGlobalOptionDefaultValues();
22
    }
23
24
    /**
25
     * Return an associative array containing all of the global configuration
26
     * options and their default values.
27
     *
28
     * @return array
29
     */
30
    public function getGlobalOptionDefaultValues()
31
    {
32
        $globalOptions =
33
        [
34
            self::PROGRESS_BAR_AUTO_DISPLAY_INTERVAL => self::DEFAULT_PROGRESS_DELAY,
35
            self::SIMULATE => false,
36
        ];
37
        return $this->trimPrefixFromGlobalOptions($globalOptions);
38
    }
39
40
    /**
41
     * Remove the 'options.' prefix from the global options list.
42
     */
43
    protected function trimPrefixFromGlobalOptions($globalOptions)
44
    {
45
        $result = [];
46
        foreach ($globalOptions as $option => $value) {
47
            $option = str_replace('options.', '', $option);
48
            $result[$option] = $value;
49
        }
50
        return $result;
51
    }
52
53
    /**
54
     * @deprecated Use $config->get(Config::SIMULATE)
55
     *
56
     * @return bool
57
     */
58
    public function isSimulated()
59
    {
60
        return $this->get(self::SIMULATE);
61
    }
62
63
    /**
64
     * @deprecated Use $config->set(Config::SIMULATE, true)
65
     *
66
     * @param bool $simulated
67
     *
68
     * @return $this
69
     */
70
    public function setSimulated($simulated = true)
71
    {
72
        return $this->set(self::SIMULATE, $simulated);
73
    }
74
75
    /**
76
     * @deprecated Use $config->get(Config::INTERACTIVE)
77
     *
78
     * @return bool
79
     */
80
    public function isInteractive()
81
    {
82
        return $this->get(self::INTERACTIVE);
83
    }
84
85
    /**
86
     * @deprecated Use $config->set(Config::INTERACTIVE, true)
87
     *
88
     * @param bool $interactive
89
     *
90
     * @return $this
91
     */
92
    public function setInteractive($interactive = true)
93
    {
94
        return $this->set(self::INTERACTIVE, $interactive);
95
    }
96
97
    /**
98
     * @deprecated Use $config->get(Config::DECORATED)
99
     *
100
     * @return bool
101
     */
102
    public function isDecorated()
103
    {
104
        return $this->get(self::DECORATED);
105
    }
106
107
    /**
108
     * @deprecated Use $config->set(Config::DECORATED, true)
109
     *
110
     * @param bool $decorated
111
     *
112
     * @return $this
113
     */
114
    public function setDecorated($decorated = true)
115
    {
116
        return $this->set(self::DECORATED, $decorated);
117
    }
118
119
    /**
120
     * @deprecated Use $config->set(Config::PROGRESS_BAR_AUTO_DISPLAY_INTERVAL, $interval)
121
     *
122
     * @param int $interval
123
     *
124
     * @return $this
125
     */
126
    public function setProgressBarAutoDisplayInterval($interval)
127
    {
128
        return $this->set(self::PROGRESS_BAR_AUTO_DISPLAY_INTERVAL, $interval);
129
    }
130
}
131