|
| 1 | +[« Back to Table Of Contents](/doc/api/index.md) |
| 2 | + |
| 3 | +# Class Argument |
| 4 | + |
| 5 | +**FQN:** [Yannoff\Component\Console\Definition\Argument][self] |
| 6 | +<br/> |
| 7 | +_**extends** [Item](/doc/api/Definition/Item.md)_ |
| 8 | +<br/> |
| 9 | + |
| 10 | + |
| 11 | +## Overview |
| 12 | + |
| 13 | +*Argument definition item* |
| 14 | +<br/><br/> |
| 15 | + |
| 16 | +**Properties** |
| 17 | + |
| 18 | +- [$default](#argumentdefault) |
| 19 | +- [$hasDefault](#argumenthasDefault) |
| 20 | +- [$help](#argumenthelp) |
| 21 | +- [$name](#argumentname) |
| 22 | +- [$type](#argumenttype) |
| 23 | + |
| 24 | +**Methods** |
| 25 | + |
| 26 | +- [__construct()](#argument__construct) |
| 27 | +- [__toString()](#argument__toString) |
| 28 | +- [getDefault()](#argumentgetDefault) |
| 29 | +- [getHelp()](#argumentgetHelp) |
| 30 | +- [getName()](#argumentgetName) |
| 31 | +- [getSynopsis()](#argumentgetSynopsis) |
| 32 | +- [getType()](#argumentgetType) |
| 33 | +- [getValidTypes()](#argumentgetValidTypes) |
| 34 | +- [hasDefault()](#argumenthasDefault) |
| 35 | +- [isMandatory()](#argumentisMandatory) |
| 36 | +- [isOptional()](#argumentisOptional) |
| 37 | +- [isRequired()](#argumentisRequired) |
| 38 | +- [isValidType()](#argumentisValidType) |
| 39 | +- [setHasDefault()](#argumentsetHasDefault) |
| 40 | + |
| 41 | +--- |
| 42 | + |
| 43 | +## Properties |
| 44 | + |
| 45 | + |
| 46 | +### <a name="default">Argument::$default</a> |
| 47 | + |
| 48 | +_Optional default value for the item_ |
| 49 | + |
| 50 | +**type**: mixed <br/> |
| 51 | +**access**: protected <br/> |
| 52 | +**inherited from:** [Item](/doc/api/Definition/Item.md#default) |
| 53 | + |
| 54 | +### <a name="hasDefault">Argument::$hasDefault</a> |
| 55 | + |
| 56 | +_Flag indicating if default value was set_ |
| 57 | + |
| 58 | +**type**: [bool][php:bool] <br/> |
| 59 | +**access**: protected <br/> |
| 60 | +**inherited from:** [Item](/doc/api/Definition/Item.md#hasDefault) |
| 61 | + |
| 62 | +### <a name="help">Argument::$help</a> |
| 63 | + |
| 64 | +_The item help/description message_ |
| 65 | + |
| 66 | +**type**: [string][php:string] <br/> |
| 67 | +**access**: protected <br/> |
| 68 | +**inherited from:** [Item](/doc/api/Definition/Item.md#help) |
| 69 | + |
| 70 | +### <a name="name">Argument::$name</a> |
| 71 | + |
| 72 | +_The item name_ |
| 73 | + |
| 74 | +**type**: [string][php:string] <br/> |
| 75 | +**access**: protected <br/> |
| 76 | +**inherited from:** [Item](/doc/api/Definition/Item.md#name) |
| 77 | + |
| 78 | +### <a name="type">Argument::$type</a> |
| 79 | + |
| 80 | +_The item type_ |
| 81 | + |
| 82 | +**type**: [int][php:int] <br/> |
| 83 | +**access**: protected <br/> |
| 84 | +**inherited from:** [Item](/doc/api/Definition/Item.md#type) |
| 85 | + |
| 86 | +--- |
| 87 | + |
| 88 | +## Methods |
| 89 | + |
| 90 | + |
| 91 | +### <a name="__construct">Argument::__construct()</a> |
| 92 | + |
| 93 | +*Argument constructor.* |
| 94 | + |
| 95 | +**access:** public <br/> |
| 96 | + |
| 97 | +#### Arguments |
| 98 | + |
| 99 | +Name|Type|Description |
| 100 | +----|----|----------- |
| 101 | +$name|[string][php:string]|The argument name |
| 102 | +$type|[int][php:int]|The argument type: optional/required |
| 103 | +$help|[string][php:string]|The argument help message |
| 104 | +$default|mixed|Optional default value for the argument |
| 105 | + |
| 106 | +#### Return value |
| 107 | + |
| 108 | +>_No return value._ |
| 109 | +
|
| 110 | + |
| 111 | +#### Exceptions |
| 112 | + |
| 113 | +Type|Description |
| 114 | +----|----------- |
| 115 | +[InvalidArgumentTypeException](/doc/api/Exception/Definition/InvalidArgumentTypeException.md)| |
| 116 | + |
| 117 | + |
| 118 | +### <a name="__toString">Argument::__toString()</a> |
| 119 | + |
| 120 | +*Default to-string type-cast conversion for Item objects* |
| 121 | + |
| 122 | +**access:** public <br/> |
| 123 | +**inherited from:** [Item](/doc/api/Definition/Item.md#__toString) <br/> |
| 124 | + |
| 125 | +#### Arguments |
| 126 | + |
| 127 | +>_No arguments._ |
| 128 | +
|
| 129 | +#### Return value |
| 130 | + |
| 131 | + |
| 132 | +**type:** [string][php:string] |
| 133 | + |
| 134 | + |
| 135 | + |
| 136 | +### <a name="getDefault">Argument::getDefault()</a> |
| 137 | + |
| 138 | +*Getter for the item default value* |
| 139 | + |
| 140 | +**access:** public <br/> |
| 141 | +**inherited from:** [Item](/doc/api/Definition/Item.md#getDefault) <br/> |
| 142 | + |
| 143 | +#### Arguments |
| 144 | + |
| 145 | +>_No arguments._ |
| 146 | +
|
| 147 | +#### Return value |
| 148 | + |
| 149 | + |
| 150 | +**type:** mixed |
| 151 | + |
| 152 | + |
| 153 | + |
| 154 | +### <a name="getHelp">Argument::getHelp()</a> |
| 155 | + |
| 156 | +*Getter for the item help message* |
| 157 | + |
| 158 | +**access:** public <br/> |
| 159 | +**inherited from:** [Item](/doc/api/Definition/Item.md#getHelp) <br/> |
| 160 | + |
| 161 | +#### Arguments |
| 162 | + |
| 163 | +>_No arguments._ |
| 164 | +
|
| 165 | +#### Return value |
| 166 | + |
| 167 | + |
| 168 | +**type:** [string][php:string] |
| 169 | + |
| 170 | + |
| 171 | + |
| 172 | +### <a name="getName">Argument::getName()</a> |
| 173 | + |
| 174 | +*Getter for the item name* |
| 175 | + |
| 176 | +**access:** public <br/> |
| 177 | +**inherited from:** [Item](/doc/api/Definition/Item.md#getName) <br/> |
| 178 | + |
| 179 | +#### Arguments |
| 180 | + |
| 181 | +>_No arguments._ |
| 182 | +
|
| 183 | +#### Return value |
| 184 | + |
| 185 | + |
| 186 | +**type:** [string][php:string] |
| 187 | + |
| 188 | + |
| 189 | + |
| 190 | +### <a name="getSynopsis">Argument::getSynopsis()</a> |
| 191 | + |
| 192 | +*Return the formatted help for the item* |
| 193 | + |
| 194 | +**access:** public <br/> |
| 195 | + |
| 196 | +#### Arguments |
| 197 | + |
| 198 | +Name|Type|Description |
| 199 | +----|----|----------- |
| 200 | +$tab|[string][php:string]|The tabulation string (defaults to `\t`) |
| 201 | +$width|[int][php:int]|Minimum width for the names column (defaults to `18`) |
| 202 | + |
| 203 | +#### Return value |
| 204 | + |
| 205 | + |
| 206 | +**type:** [string][php:string] |
| 207 | + |
| 208 | + |
| 209 | + |
| 210 | +### <a name="getType">Argument::getType()</a> |
| 211 | + |
| 212 | +*Getter for the item type* |
| 213 | + |
| 214 | +**access:** public <br/> |
| 215 | +**inherited from:** [Item](/doc/api/Definition/Item.md#getType) <br/> |
| 216 | + |
| 217 | +#### Arguments |
| 218 | + |
| 219 | +>_No arguments._ |
| 220 | +
|
| 221 | +#### Return value |
| 222 | + |
| 223 | + |
| 224 | +**type:** [int][php:int] |
| 225 | + |
| 226 | + |
| 227 | + |
| 228 | +### <a name="getValidTypes">Argument::getValidTypes()</a> |
| 229 | + |
| 230 | +*Give the authorized values for the type property* |
| 231 | + |
| 232 | +**access:** public <br/> |
| 233 | + |
| 234 | +#### Arguments |
| 235 | + |
| 236 | +>_No arguments._ |
| 237 | +
|
| 238 | +#### Return value |
| 239 | + |
| 240 | + |
| 241 | +**type:** [array][php:array] |
| 242 | + |
| 243 | + |
| 244 | + |
| 245 | +### <a name="hasDefault">Argument::hasDefault()</a> |
| 246 | + |
| 247 | +*Getter for the hasDefault flag* |
| 248 | + |
| 249 | +**access:** public <br/> |
| 250 | +**inherited from:** [Item](/doc/api/Definition/Item.md#hasDefault) <br/> |
| 251 | + |
| 252 | +#### Arguments |
| 253 | + |
| 254 | +>_No arguments._ |
| 255 | +
|
| 256 | +#### Return value |
| 257 | + |
| 258 | + |
| 259 | +**type:** [bool][php:bool] |
| 260 | + |
| 261 | + |
| 262 | + |
| 263 | +### <a name="isMandatory">Argument::isMandatory()</a> |
| 264 | + |
| 265 | +*True if the argument is required AND has no default value set<br/>Indeed a required argument with its default value set is de facto not mandatory* |
| 266 | + |
| 267 | +**access:** public <br/> |
| 268 | + |
| 269 | +#### Arguments |
| 270 | + |
| 271 | +>_No arguments._ |
| 272 | +
|
| 273 | +#### Return value |
| 274 | + |
| 275 | + |
| 276 | +**type:** [bool][php:bool] |
| 277 | + |
| 278 | + |
| 279 | + |
| 280 | +### <a name="isOptional">Argument::isOptional()</a> |
| 281 | + |
| 282 | +*True if the argument is typed as "optional"* |
| 283 | + |
| 284 | +**access:** public <br/> |
| 285 | + |
| 286 | +#### Arguments |
| 287 | + |
| 288 | +>_No arguments._ |
| 289 | +
|
| 290 | +#### Return value |
| 291 | + |
| 292 | + |
| 293 | +**type:** [bool][php:bool] |
| 294 | + |
| 295 | + |
| 296 | + |
| 297 | +### <a name="isRequired">Argument::isRequired()</a> |
| 298 | + |
| 299 | +*True if the argument is typed as required* |
| 300 | + |
| 301 | +**access:** public <br/> |
| 302 | + |
| 303 | +#### Arguments |
| 304 | + |
| 305 | +>_No arguments._ |
| 306 | +
|
| 307 | +#### Return value |
| 308 | + |
| 309 | + |
| 310 | +**type:** [bool][php:bool] |
| 311 | + |
| 312 | + |
| 313 | + |
| 314 | +### <a name="isValidType">Argument::isValidType()</a> |
| 315 | + |
| 316 | +*Check whether the given type as a valid value* |
| 317 | + |
| 318 | +**access:** public <br/> |
| 319 | +**inherited from:** [Item](/doc/api/Definition/Item.md#isValidType) <br/> |
| 320 | + |
| 321 | +#### Arguments |
| 322 | + |
| 323 | +Name|Type|Description |
| 324 | +----|----|----------- |
| 325 | +$type|[int][php:int]| |
| 326 | + |
| 327 | +#### Return value |
| 328 | + |
| 329 | + |
| 330 | +**type:** [bool][php:bool] |
| 331 | + |
| 332 | + |
| 333 | + |
| 334 | +### <a name="setHasDefault">Argument::setHasDefault()</a> |
| 335 | + |
| 336 | +*Setter for the $hasDefault flag* |
| 337 | + |
| 338 | +**access:** public <br/> |
| 339 | +**inherited from:** [Item](/doc/api/Definition/Item.md#setHasDefault) <br/> |
| 340 | + |
| 341 | +#### Arguments |
| 342 | + |
| 343 | +Name|Type|Description |
| 344 | +----|----|----------- |
| 345 | +$hasDefault|[bool][php:bool]| |
| 346 | + |
| 347 | +#### Return value |
| 348 | + |
| 349 | + |
| 350 | +**type:** [self][self] |
| 351 | + |
| 352 | + |
| 353 | + |
| 354 | + |
| 355 | +[self]: Argument.md |
| 356 | +[php:array]: https://www.php.net/manual/language.types.array.php "PHP Built-in: array" |
| 357 | +[php:int]: https://www.php.net/manual/language.types.integer.php "PHP Built-in: int" |
| 358 | +[php:integer]: https://www.php.net/manual/language.types.integer.php "PHP Built-in: integer" |
| 359 | +[php:bool]: https://www.php.net/manual/language.types.boolean.php "PHP Built-in: bool" |
| 360 | +[php:true]: https://www.php.net/manual/language.types.boolean.php "PHP Built-in: true" |
| 361 | +[php:false]: https://www.php.net/manual/language.types.boolean.php "PHP Built-in: false" |
| 362 | +[php:boolean]: https://www.php.net/manual/language.types.boolean.php "PHP Built-in: boolean" |
| 363 | +[php:string]: https://www.php.net/manual/language.types.string.php "PHP Built-in: string" |
| 364 | +[php:float]: https://www.php.net/manual/language.types.float.php "PHP Built-in: float" |
| 365 | +[php:object]: https://www.php.net/manual/language.types.object.php "PHP Built-in: object" |
| 366 | +[php:null]: https://www.php.net/manual/language.types.null.php "PHP Built-in: null" |
| 367 | +[php:callable]: https://www.php.net/manual/language.types.callable.php "PHP Built-in: callable" |
| 368 | +[php:resource]: https://www.php.net/manual/language.types.resource.php "PHP Built-in: resource" |
| 369 | +[php:Closure]: https://www.php.net/manual/class.closure.php "PHP Built-in: Closure" |
| 370 | +[php:Error]: https://www.php.net/manual/class.error.php "PHP Built-in: Error" |
| 371 | +[php:Throwable]: https://www.php.net/manual/class.throwable.php "PHP Built-in: Throwable" |
| 372 | +[php:Exception]: https://www.php.net/manual/class.exception.php "PHP Built-in: Exception" |
| 373 | +[php:LogicException]: https://www.php.net/manual/class.logicexception.php "PHP Built-in: LogicException" |
| 374 | +[php:RuntimeException]: https://www.php.net/manual/class.runtimeexception.php "PHP Built-in: RuntimeException" |
| 375 | + |
| 376 | +[« Back to Table Of Contents](/doc/api/index.md) |
| 377 | + |
0 commit comments