1 | <?php |
||
8 | class DefaultsWithDescriptions |
||
9 | { |
||
10 | /** |
||
11 | * @var array Associative array of key : default mappings |
||
12 | */ |
||
13 | protected $values; |
||
14 | |||
15 | /** |
||
16 | * @var array Associative array used like a set to indicate default value |
||
17 | * exists for the key. |
||
18 | */ |
||
19 | protected $hasDefault; |
||
20 | |||
21 | /** |
||
22 | * @var array Associative array of key : description mappings |
||
23 | */ |
||
24 | protected $descriptions; |
||
25 | |||
26 | /** |
||
27 | * @var mixed Default value that the default value of items in |
||
28 | * the collection should take when not specified in the 'add' method. |
||
29 | */ |
||
30 | protected $defaultDefault; |
||
31 | |||
32 | public function __construct($values = [], $defaultDefault = null) |
||
39 | |||
40 | /** |
||
41 | * Return just the key : default values mapping |
||
42 | * |
||
43 | * @return array |
||
44 | */ |
||
45 | public function getValues() |
||
49 | |||
50 | /** |
||
51 | * Check to see whether the speicifed key exists in the collection. |
||
52 | * |
||
53 | * @param string $key |
||
54 | * @return boolean |
||
55 | */ |
||
56 | public function exists($key) |
||
60 | |||
61 | /** |
||
62 | * Get the value of one entry. |
||
63 | * |
||
64 | * @param string $key The key of the item. |
||
65 | * @return string |
||
66 | */ |
||
67 | public function get($key) |
||
74 | |||
75 | /** |
||
76 | * Get the description of one entry. |
||
77 | * |
||
78 | * @param string $key The key of the item. |
||
79 | * @return string |
||
80 | */ |
||
81 | public function getDescription($key) |
||
88 | |||
89 | /** |
||
90 | * Add another argument to this command. |
||
91 | * |
||
92 | * @param string $key Name of the argument. |
||
93 | * @param string $description Help text for the argument. |
||
94 | * @param mixed $defaultValue The default value for the argument. |
||
95 | */ |
||
96 | public function add($key, $description = '', $defaultValue = null) |
||
106 | |||
107 | /** |
||
108 | * Change the default value of an entry. |
||
109 | * |
||
110 | * @param string $key |
||
111 | * @param mixed $defaultValue |
||
112 | */ |
||
113 | public function setDefaultValue($key, $defaultValue) |
||
118 | |||
119 | /** |
||
120 | * Check to see if the named argument definitively has a default value. |
||
121 | * |
||
122 | * @param string $key |
||
123 | * @return bool |
||
124 | */ |
||
125 | public function hasDefault($key) |
||
129 | |||
130 | /** |
||
131 | * Remove an entry |
||
132 | * |
||
133 | * @param string $key The entry to remove |
||
134 | */ |
||
135 | public function clear($key) |
||
140 | |||
141 | /** |
||
142 | * Rename an existing option to something else. |
||
143 | */ |
||
144 | public function rename($oldName, $newName) |
||
149 | } |
||
150 |