Ubiquity 2.5.2
php rapid development framework
Loading...
Searching...
No Matches
Parameter.php
Go to the documentation of this file.
1<?php
3
13class 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() {
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 = "") {
94 }
95}
static colorize($string, $color=null, $bgColor=null)
Returns a colored string.
Represent a parameter for a command.
Definition Parameter.php:13
static create(string $name, string $description, array $values, string $defaultValue="")
Return a new parameter.
Definition Parameter.php:92
__construct(string $name='', string $description='', array $values=[], string $defaultValue="")
Definition Parameter.php:23