1 | <?php |
||
7 | class Parameter |
||
8 | { |
||
9 | /** |
||
10 | * Name of the parameter |
||
11 | * |
||
12 | * @var string |
||
13 | **/ |
||
14 | private $name; |
||
15 | |||
16 | /** |
||
17 | * Human readable description |
||
18 | * |
||
19 | * @var string |
||
20 | **/ |
||
21 | private $description; |
||
22 | |||
23 | /** |
||
24 | * The default value |
||
25 | * |
||
26 | * @var mixed |
||
27 | **/ |
||
28 | private $defaultValue; |
||
29 | |||
30 | /** |
||
31 | * Is there a default value? |
||
32 | * |
||
33 | * This is checked outside of the $defaultValue property, as `null` is a |
||
34 | * valid default value |
||
35 | * |
||
36 | * @var bool |
||
37 | **/ |
||
38 | private $hasDefaultValue = false; |
||
39 | |||
40 | /** |
||
41 | * Constructor |
||
42 | * |
||
43 | * @param string $name name of the parameter |
||
44 | * @param string $description (optional) human readable description |
||
45 | * @return void |
||
|
|||
46 | **/ |
||
47 | public function __construct($name, $description = null) |
||
58 | |||
59 | /** |
||
60 | * Get the name/key of the parameter |
||
61 | * |
||
62 | * @return string |
||
63 | */ |
||
64 | public function getName() |
||
68 | |||
69 | /** |
||
70 | * Set the name/key of the parameter |
||
71 | * |
||
72 | * @param string $name |
||
73 | * @return Parameter |
||
74 | */ |
||
75 | public function setName($name) |
||
81 | |||
82 | /** |
||
83 | * Get the description in human readable form |
||
84 | * |
||
85 | * @return string |
||
86 | */ |
||
87 | public function getDescription() |
||
91 | |||
92 | /** |
||
93 | * Set the description in human readable form |
||
94 | * |
||
95 | * @param string $description |
||
96 | * @return Parameter |
||
97 | */ |
||
98 | public function setDescription($description) |
||
104 | |||
105 | /** |
||
106 | * Get the default value |
||
107 | * |
||
108 | * @return mixed |
||
109 | */ |
||
110 | public function getDefaultValue() |
||
114 | |||
115 | /** |
||
116 | * Set the default value |
||
117 | * |
||
118 | * @param mixed $defaultValue |
||
119 | * @return Parameter |
||
120 | */ |
||
121 | public function setDefaultValue($defaultValue) |
||
129 | |||
130 | /** |
||
131 | * Does this parameter have a default value? |
||
132 | * |
||
133 | * @return bool |
||
134 | **/ |
||
135 | public function hasDefaultValue() |
||
139 | |||
140 | /** |
||
141 | * Set the default value flag |
||
142 | * |
||
143 | * @param bool $hasDefaultValue |
||
144 | * @return Parameter |
||
145 | **/ |
||
146 | private function setHasDefaultValue($hasDefaultValue = true) |
||
152 | } |
||
153 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.