Ubiquity
2.5.2
php rapid development framework
Loading...
Searching...
No Matches
Parameter.php
Go to the documentation of this file.
1
<?php
2
namespace
Ubiquity\devtools\cmd
;
3
13
class
Parameter
{
14
15
protected
$name
;
16
17
protected
$description
;
18
19
protected
$values
;
20
21
protected
$defaultValue
;
22
23
public
function
__construct
(
string
$name
=
''
,
string
$description
=
''
, array
$values
= [],
string
$defaultValue
=
""
) {
24
$this->name =
$name
;
25
$this->description =
$description
;
26
$this->values =
$values
;
27
$this->defaultValue =
$defaultValue
;
28
}
29
30
public
function
__toString
() {
31
$dec =
"\t\t\t"
;
32
$result =
"\tshortcut of --<b>"
. $this->name .
"</b>\n"
. $dec .
$this->description
;
33
if
(\count($this->values) > 0) {
34
$result .=
"\n"
. $dec .
"Possibles values :"
;
35
$result .=
"\n"
. $dec .
ConsoleFormatter::colorize
(implode(
","
, $this->values),
ConsoleFormatter::DARK_GREY
);
36
}
37
if
($this->defaultValue !==
""
) {
38
$result .=
"\n"
. $dec .
"Default : ["
.
ConsoleFormatter::colorize
($this->defaultValue,
ConsoleFormatter::GREEN
) .
"]"
;
39
}
40
return
$result;
41
}
42
43
public
function
getName
() {
44
return
$this->name
;
45
}
46
47
public
function
setName
(
$name
) {
48
$this->name =
$name
;
49
return
$this;
50
}
51
52
public
function
getDescription
() {
53
return
$this->description
;
54
}
55
56
public
function
setDescription
(
$description
) {
57
$this->description =
$description
;
58
return
$this;
59
}
60
61
public
function
getValues
() {
62
return
$this->values
;
63
}
64
65
public
function
setValues
(
$values
) {
66
$this->values =
$values
;
67
return
$this;
68
}
69
70
public
function
getDefaultValue
() {
71
return
$this->defaultValue
;
72
}
73
74
public
function
setDefaultValue
(
$defaultValue
) {
75
$this->defaultValue =
$defaultValue
;
76
return
$this;
77
}
78
92
public
static
function
create
(
string
$name
,
string
$description
, array
$values
,
string
$defaultValue
=
""
) {
93
return
new
Parameter
(
$name
,
$description
,
$values
,
$defaultValue
);
94
}
95
}
Ubiquity\devtools\cmd\ConsoleFormatter\colorize
static colorize($string, $color=null, $bgColor=null)
Returns a colored string.
Definition
ConsoleFormatter.php:28
Ubiquity\devtools\cmd\ConsoleFormatter\GREEN
const GREEN
Definition
ConsoleFormatter.php:14
Ubiquity\devtools\cmd\ConsoleFormatter\DARK_GREY
const DARK_GREY
Definition
ConsoleFormatter.php:14
Ubiquity\devtools\cmd\Parameter
Represent a parameter for a command.
Definition
Parameter.php:13
Ubiquity\devtools\cmd\Parameter\getDescription
getDescription()
Definition
Parameter.php:52
Ubiquity\devtools\cmd\Parameter\setName
setName($name)
Definition
Parameter.php:47
Ubiquity\devtools\cmd\Parameter\setDescription
setDescription($description)
Definition
Parameter.php:56
Ubiquity\devtools\cmd\Parameter\setDefaultValue
setDefaultValue($defaultValue)
Definition
Parameter.php:74
Ubiquity\devtools\cmd\Parameter\getName
getName()
Definition
Parameter.php:43
Ubiquity\devtools\cmd\Parameter\create
static create(string $name, string $description, array $values, string $defaultValue="")
Return a new parameter.
Definition
Parameter.php:92
Ubiquity\devtools\cmd\Parameter\__construct
__construct(string $name='', string $description='', array $values=[], string $defaultValue="")
Definition
Parameter.php:23
Ubiquity\devtools\cmd\Parameter\setValues
setValues($values)
Definition
Parameter.php:65
Ubiquity\devtools\cmd\Parameter\getValues
getValues()
Definition
Parameter.php:61
Ubiquity\devtools\cmd\Parameter\__toString
__toString()
Definition
Parameter.php:30
Ubiquity\devtools\cmd\Parameter\$description
$description
Definition
Parameter.php:17
Ubiquity\devtools\cmd\Parameter\$defaultValue
$defaultValue
Definition
Parameter.php:21
Ubiquity\devtools\cmd\Parameter\$name
$name
Definition
Parameter.php:15
Ubiquity\devtools\cmd\Parameter\getDefaultValue
getDefaultValue()
Definition
Parameter.php:70
Ubiquity\devtools\cmd\Parameter\$values
$values
Definition
Parameter.php:19
Ubiquity\devtools\cmd
Definition
Command.php:2
C:
Users
myadd
Documents
GitHub
ubiquity-doc-api
vendor
phpmv
ubiquity-commands
src
Ubiquity
devtools
cmd
Parameter.php
Generated on Sun Dec 10 2023 15:04:06 for
Ubiquity
by
doxygen
1.9.8