@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | */ |
24 | 24 | class ConvertHelper_ByteConverter |
25 | 25 | { |
26 | - /** |
|
27 | - * @var int |
|
28 | - */ |
|
26 | + /** |
|
27 | + * @var int |
|
28 | + */ |
|
29 | 29 | protected $bytes; |
30 | 30 | |
31 | 31 | public function __construct(int $bytes) |
@@ -39,12 +39,12 @@ discard block |
||
39 | 39 | } |
40 | 40 | } |
41 | 41 | |
42 | - /** |
|
43 | - * Detects the size matching the byte value for the specified base. |
|
44 | - * |
|
45 | - * @param int $base |
|
46 | - * @return ConvertHelper_StorageSizeEnum_Size |
|
47 | - */ |
|
42 | + /** |
|
43 | + * Detects the size matching the byte value for the specified base. |
|
44 | + * |
|
45 | + * @param int $base |
|
46 | + * @return ConvertHelper_StorageSizeEnum_Size |
|
47 | + */ |
|
48 | 48 | protected function detectSize(int $base) : ConvertHelper_StorageSizeEnum_Size |
49 | 49 | { |
50 | 50 | $sizes = $this->getSizesSorted($base); |
@@ -70,13 +70,13 @@ discard block |
||
70 | 70 | return ConvertHelper_StorageSizeEnum::getSizeByName('b'); |
71 | 71 | } |
72 | 72 | |
73 | - /** |
|
74 | - * Retrieves all storage sizes for the specified base, |
|
75 | - * sorted from smallest byte size to highest. |
|
76 | - * |
|
77 | - * @param int $base |
|
78 | - * @return \AppUtils\ConvertHelper_StorageSizeEnum_Size[] |
|
79 | - */ |
|
73 | + /** |
|
74 | + * Retrieves all storage sizes for the specified base, |
|
75 | + * sorted from smallest byte size to highest. |
|
76 | + * |
|
77 | + * @param int $base |
|
78 | + * @return \AppUtils\ConvertHelper_StorageSizeEnum_Size[] |
|
79 | + */ |
|
80 | 80 | protected function getSizesSorted(int $base) |
81 | 81 | { |
82 | 82 | $sizes = ConvertHelper_StorageSizeEnum::getSizesByBase($base); |
@@ -89,16 +89,16 @@ discard block |
||
89 | 89 | return $sizes; |
90 | 90 | } |
91 | 91 | |
92 | - /** |
|
93 | - * Converts the byte value to a human readable string, e.g. "5 KB", "140 MB". |
|
94 | - * |
|
95 | - * @param int $precision The amount of decimals (rounded up) |
|
96 | - * @param int $base The base to calculate bytes with. |
|
97 | - * @return string |
|
98 | - * |
|
99 | - * @see ConvertHelper_StorageSizeEnum::BASE_10 |
|
100 | - * @see ConvertHelper_StorageSizeEnum::BASE_2 |
|
101 | - */ |
|
92 | + /** |
|
93 | + * Converts the byte value to a human readable string, e.g. "5 KB", "140 MB". |
|
94 | + * |
|
95 | + * @param int $precision The amount of decimals (rounded up) |
|
96 | + * @param int $base The base to calculate bytes with. |
|
97 | + * @return string |
|
98 | + * |
|
99 | + * @see ConvertHelper_StorageSizeEnum::BASE_10 |
|
100 | + * @see ConvertHelper_StorageSizeEnum::BASE_2 |
|
101 | + */ |
|
102 | 102 | public function toString(int $precision, int $base=ConvertHelper_StorageSizeEnum::BASE_10) : string |
103 | 103 | { |
104 | 104 | $size = $this->detectSize($base); |
@@ -106,13 +106,13 @@ discard block |
||
106 | 106 | return round($this->bytes / $size->getBytes(), $precision) . ' ' . $size->getSuffix(); |
107 | 107 | } |
108 | 108 | |
109 | - /** |
|
110 | - * Converts the byte value to the amount of the corresponding units (KB, MB...). |
|
111 | - * |
|
112 | - * @param int $precision The amount of decimals (rounded up) |
|
113 | - * @param string $sizeName The lowercase storage size name (e.g. "kb", "kib") |
|
114 | - * @return float |
|
115 | - */ |
|
109 | + /** |
|
110 | + * Converts the byte value to the amount of the corresponding units (KB, MB...). |
|
111 | + * |
|
112 | + * @param int $precision The amount of decimals (rounded up) |
|
113 | + * @param string $sizeName The lowercase storage size name (e.g. "kb", "kib") |
|
114 | + * @return float |
|
115 | + */ |
|
116 | 116 | public function toNumber(int $precision, string $sizeName) : float |
117 | 117 | { |
118 | 118 | $size = ConvertHelper_StorageSizeEnum::getSizeByName($sizeName); |
@@ -120,56 +120,56 @@ discard block |
||
120 | 120 | return round($this->bytes / $size->getBytes(), $precision); |
121 | 121 | } |
122 | 122 | |
123 | - /** |
|
124 | - * Converts the bytes to Kilobytes. |
|
125 | - * |
|
126 | - * @param int $precision Amount of decimals (rounded up) |
|
127 | - * @return float |
|
128 | - */ |
|
123 | + /** |
|
124 | + * Converts the bytes to Kilobytes. |
|
125 | + * |
|
126 | + * @param int $precision Amount of decimals (rounded up) |
|
127 | + * @return float |
|
128 | + */ |
|
129 | 129 | public function toKilobytes(int $precision=1) : float |
130 | 130 | { |
131 | 131 | return $this->toNumber($precision, 'kb'); |
132 | 132 | } |
133 | 133 | |
134 | - /** |
|
135 | - * Converts the bytes to Megabytes. |
|
136 | - * |
|
137 | - * @param int $precision Amount of decimals (rounded up) |
|
138 | - * @return float |
|
139 | - */ |
|
134 | + /** |
|
135 | + * Converts the bytes to Megabytes. |
|
136 | + * |
|
137 | + * @param int $precision Amount of decimals (rounded up) |
|
138 | + * @return float |
|
139 | + */ |
|
140 | 140 | public function toMegabytes(int $precision=1) : float |
141 | 141 | { |
142 | 142 | return $this->toNumber($precision, 'mb'); |
143 | 143 | } |
144 | 144 | |
145 | - /** |
|
146 | - * Converts the bytes to Gigabytes. |
|
147 | - * |
|
148 | - * @param int $precision Amount of decimals (rounded up) |
|
149 | - * @return float |
|
150 | - */ |
|
145 | + /** |
|
146 | + * Converts the bytes to Gigabytes. |
|
147 | + * |
|
148 | + * @param int $precision Amount of decimals (rounded up) |
|
149 | + * @return float |
|
150 | + */ |
|
151 | 151 | public function toGigabytes(int $precision=1) : float |
152 | 152 | { |
153 | 153 | return $this->toNumber($precision, 'gb'); |
154 | 154 | } |
155 | 155 | |
156 | - /** |
|
157 | - * Converts the bytes to Terabytes. |
|
158 | - * |
|
159 | - * @param int $precision Amount of decimals (rounded up) |
|
160 | - * @return float |
|
161 | - */ |
|
156 | + /** |
|
157 | + * Converts the bytes to Terabytes. |
|
158 | + * |
|
159 | + * @param int $precision Amount of decimals (rounded up) |
|
160 | + * @return float |
|
161 | + */ |
|
162 | 162 | public function toTerabytes(int $precision=1) : float |
163 | 163 | { |
164 | 164 | return $this->toNumber($precision, 'tb'); |
165 | 165 | } |
166 | 166 | |
167 | - /** |
|
168 | - * Converts the bytes to Petabytes. |
|
169 | - * |
|
170 | - * @param int $precision Amount of decimals (rounded up) |
|
171 | - * @return float |
|
172 | - */ |
|
167 | + /** |
|
168 | + * Converts the bytes to Petabytes. |
|
169 | + * |
|
170 | + * @param int $precision Amount of decimals (rounded up) |
|
171 | + * @return float |
|
172 | + */ |
|
173 | 173 | public function toPetabytes(int $precision=1) : float |
174 | 174 | { |
175 | 175 | return $this->toNumber($precision, 'pb'); |
@@ -25,34 +25,34 @@ |
||
25 | 25 | */ |
26 | 26 | class ConvertHelper_StorageSizeEnum_Size |
27 | 27 | { |
28 | - /** |
|
29 | - * @var string |
|
30 | - */ |
|
28 | + /** |
|
29 | + * @var string |
|
30 | + */ |
|
31 | 31 | protected $name; |
32 | 32 | |
33 | - /** |
|
34 | - * @var int |
|
35 | - */ |
|
33 | + /** |
|
34 | + * @var int |
|
35 | + */ |
|
36 | 36 | protected $base; |
37 | 37 | |
38 | - /** |
|
39 | - * @var int |
|
40 | - */ |
|
38 | + /** |
|
39 | + * @var int |
|
40 | + */ |
|
41 | 41 | protected $exponent; |
42 | 42 | |
43 | - /** |
|
44 | - * @var string |
|
45 | - */ |
|
43 | + /** |
|
44 | + * @var string |
|
45 | + */ |
|
46 | 46 | protected $singular; |
47 | 47 | |
48 | - /** |
|
49 | - * @var string |
|
50 | - */ |
|
48 | + /** |
|
49 | + * @var string |
|
50 | + */ |
|
51 | 51 | protected $plural; |
52 | 52 | |
53 | - /** |
|
54 | - * @var string |
|
55 | - */ |
|
53 | + /** |
|
54 | + * @var string |
|
55 | + */ |
|
56 | 56 | protected $suffix; |
57 | 57 | |
58 | 58 | public function __construct(string $name, int $base, int $exponent, string $suffix, string $singular, string $plural) |
@@ -28,20 +28,20 @@ discard block |
||
28 | 28 | $this->parse(); |
29 | 29 | } |
30 | 30 | |
31 | - /** |
|
32 | - * Retrieves an indexed array with accept mime types |
|
33 | - * that the client sent, in the order of preference |
|
34 | - * the client specified. |
|
35 | - * |
|
36 | - * Example: |
|
37 | - * |
|
38 | - * array( |
|
39 | - * 'text/html', |
|
40 | - * 'application/xhtml+xml', |
|
41 | - * 'image/webp' |
|
42 | - * ... |
|
43 | - * ) |
|
44 | - */ |
|
31 | + /** |
|
32 | + * Retrieves an indexed array with accept mime types |
|
33 | + * that the client sent, in the order of preference |
|
34 | + * the client specified. |
|
35 | + * |
|
36 | + * Example: |
|
37 | + * |
|
38 | + * array( |
|
39 | + * 'text/html', |
|
40 | + * 'application/xhtml+xml', |
|
41 | + * 'image/webp' |
|
42 | + * ... |
|
43 | + * ) |
|
44 | + */ |
|
45 | 45 | public function getMimeStrings() : array |
46 | 46 | { |
47 | 47 | $result = array(); |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | return $result; |
55 | 55 | } |
56 | 56 | |
57 | - /** |
|
58 | - * Checks that an accept header string exists, and tries to parse it. |
|
59 | - */ |
|
57 | + /** |
|
58 | + * Checks that an accept header string exists, and tries to parse it. |
|
59 | + */ |
|
60 | 60 | protected function parse() : void |
61 | 61 | { |
62 | 62 | // we may be in a CLI environment where the headers |
@@ -68,11 +68,11 @@ discard block |
||
68 | 68 | $this->headers = $this->parseHeader($_SERVER['HTTP_ACCEPT']); |
69 | 69 | } |
70 | 70 | |
71 | - /** |
|
72 | - * Splits the accept header string and parses the mime types. |
|
73 | - * |
|
74 | - * @param string $acceptHeader |
|
75 | - */ |
|
71 | + /** |
|
72 | + * Splits the accept header string and parses the mime types. |
|
73 | + * |
|
74 | + * @param string $acceptHeader |
|
75 | + */ |
|
76 | 76 | protected function parseHeader(string $acceptHeader) : array |
77 | 77 | { |
78 | 78 | $tokens = preg_split('/\s*,\s*/', $acceptHeader); |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | return $accept; |
90 | 90 | } |
91 | 91 | |
92 | - /** |
|
93 | - * Parses a single mime type entry. |
|
94 | - * |
|
95 | - * @param int $i The position in the accept string |
|
96 | - * @param string $mime The mime type |
|
97 | - * @return array |
|
98 | - */ |
|
92 | + /** |
|
93 | + * Parses a single mime type entry. |
|
94 | + * |
|
95 | + * @param int $i The position in the accept string |
|
96 | + * @param string $mime The mime type |
|
97 | + * @return array |
|
98 | + */ |
|
99 | 99 | protected function parseEntry(int $i, string $mime) : array |
100 | 100 | { |
101 | 101 | $entry = array( |
@@ -125,14 +125,14 @@ discard block |
||
125 | 125 | return $entry; |
126 | 126 | } |
127 | 127 | |
128 | - /** |
|
129 | - * Sorts the mime types collection, first by quality |
|
130 | - * and then by position in the list. |
|
131 | - * |
|
132 | - * @param array $a |
|
133 | - * @param array $b |
|
134 | - * @return number |
|
135 | - */ |
|
128 | + /** |
|
129 | + * Sorts the mime types collection, first by quality |
|
130 | + * and then by position in the list. |
|
131 | + * |
|
132 | + * @param array $a |
|
133 | + * @param array $b |
|
134 | + * @return number |
|
135 | + */ |
|
136 | 136 | protected function sortMimeTypes(array $a, array $b) |
137 | 137 | { |
138 | 138 | /* first tier: highest q factor wins */ |
@@ -22,9 +22,9 @@ |
||
22 | 22 | { |
23 | 23 | use Traits_Optionable; |
24 | 24 | |
25 | - /** |
|
26 | - * @var Request_Param |
|
27 | - */ |
|
25 | + /** |
|
26 | + * @var Request_Param |
|
27 | + */ |
|
28 | 28 | protected $param; |
29 | 29 | |
30 | 30 | protected $value; |
@@ -6,9 +6,9 @@ |
||
6 | 6 | |
7 | 7 | abstract class VariableInfo_Renderer_String extends VariableInfo_Renderer |
8 | 8 | { |
9 | - /** |
|
10 | - * @var mixed |
|
11 | - */ |
|
9 | + /** |
|
10 | + * @var mixed |
|
11 | + */ |
|
12 | 12 | protected $value; |
13 | 13 | |
14 | 14 | protected function init() |
@@ -6,19 +6,19 @@ discard block |
||
6 | 6 | |
7 | 7 | abstract class VariableInfo_Renderer |
8 | 8 | { |
9 | - /** |
|
10 | - * @var mixed |
|
11 | - */ |
|
9 | + /** |
|
10 | + * @var mixed |
|
11 | + */ |
|
12 | 12 | protected $value; |
13 | 13 | |
14 | - /** |
|
15 | - * @var VariableInfo |
|
16 | - */ |
|
14 | + /** |
|
15 | + * @var VariableInfo |
|
16 | + */ |
|
17 | 17 | protected $info; |
18 | 18 | |
19 | - /** |
|
20 | - * @var string |
|
21 | - */ |
|
19 | + /** |
|
20 | + * @var string |
|
21 | + */ |
|
22 | 22 | protected $type; |
23 | 23 | |
24 | 24 | public function __construct(VariableInfo $info) |
@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | |
32 | 32 | abstract protected function init(); |
33 | 33 | |
34 | - /** |
|
35 | - * Renders the value to the target format. |
|
36 | - * |
|
37 | - * @return mixed |
|
38 | - */ |
|
34 | + /** |
|
35 | + * Renders the value to the target format. |
|
36 | + * |
|
37 | + * @return mixed |
|
38 | + */ |
|
39 | 39 | public function render() |
40 | 40 | { |
41 | 41 | return $this->_render(); |
@@ -32,23 +32,23 @@ |
||
32 | 32 | $this->info = $info; |
33 | 33 | } |
34 | 34 | |
35 | - /** |
|
36 | - * Enables the authentication information in the URL, |
|
37 | - * if a username and password are present. |
|
38 | - * |
|
39 | - * @param bool $enable Whether to turn it on or off. |
|
40 | - * @return URLInfo_Normalizer |
|
41 | - */ |
|
35 | + /** |
|
36 | + * Enables the authentication information in the URL, |
|
37 | + * if a username and password are present. |
|
38 | + * |
|
39 | + * @param bool $enable Whether to turn it on or off. |
|
40 | + * @return URLInfo_Normalizer |
|
41 | + */ |
|
42 | 42 | public function enableAuth(bool $enable=true) : URLInfo_Normalizer |
43 | 43 | { |
44 | 44 | $this->auth = $enable; |
45 | 45 | return $this; |
46 | 46 | } |
47 | 47 | |
48 | - /** |
|
49 | - * Retrieves the normalized URL. |
|
50 | - * @return string |
|
51 | - */ |
|
48 | + /** |
|
49 | + * Retrieves the normalized URL. |
|
50 | + * @return string |
|
51 | + */ |
|
52 | 52 | public function normalize() : string |
53 | 53 | { |
54 | 54 | $method = 'normalize_'.$this->info->getType(); |
@@ -27,14 +27,14 @@ |
||
27 | 27 | */ |
28 | 28 | protected $param; |
29 | 29 | |
30 | - /** |
|
31 | - * @var mixed |
|
32 | - */ |
|
30 | + /** |
|
31 | + * @var mixed |
|
32 | + */ |
|
33 | 33 | protected $value; |
34 | 34 | |
35 | - /** |
|
36 | - * @var bool |
|
37 | - */ |
|
35 | + /** |
|
36 | + * @var bool |
|
37 | + */ |
|
38 | 38 | protected $isSubvalue = false; |
39 | 39 | |
40 | 40 | public function __construct(Request_Param $param, bool $subval) |
@@ -114,18 +114,18 @@ discard block |
||
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
117 | - /** |
|
118 | - * Adds a callback as a validation method. The callback gets the |
|
119 | - * value to validate as first parameter, and any additional |
|
120 | - * parameters passed here get appended to that. |
|
121 | - * |
|
122 | - * The callback must return boolean true or false depending on |
|
123 | - * whether the value is valid. |
|
124 | - * |
|
125 | - * @param callable $callback |
|
126 | - * @param array $args |
|
127 | - * @return Request_Param |
|
128 | - */ |
|
117 | + /** |
|
118 | + * Adds a callback as a validation method. The callback gets the |
|
119 | + * value to validate as first parameter, and any additional |
|
120 | + * parameters passed here get appended to that. |
|
121 | + * |
|
122 | + * The callback must return boolean true or false depending on |
|
123 | + * whether the value is valid. |
|
124 | + * |
|
125 | + * @param callable $callback |
|
126 | + * @param array $args |
|
127 | + * @return Request_Param |
|
128 | + */ |
|
129 | 129 | public function setCallback($callback, array $args=array()) : Request_Param |
130 | 130 | { |
131 | 131 | if(!is_callable($callback)) { |
@@ -189,12 +189,12 @@ discard block |
||
189 | 189 | return $value; |
190 | 190 | } |
191 | 191 | |
192 | - /** |
|
193 | - * Runs the value through all validations that were added. |
|
194 | - * |
|
195 | - * @param mixed $value |
|
196 | - * @return mixed |
|
197 | - */ |
|
192 | + /** |
|
193 | + * Runs the value through all validations that were added. |
|
194 | + * |
|
195 | + * @param mixed $value |
|
196 | + * @return mixed |
|
197 | + */ |
|
198 | 198 | protected function applyValidations($value, bool $subval=false) |
199 | 199 | { |
200 | 200 | // go through all enqueued validations in turn, each time |
@@ -207,17 +207,17 @@ discard block |
||
207 | 207 | return $value; |
208 | 208 | } |
209 | 209 | |
210 | - /** |
|
211 | - * Validates the specified value using the validation type. Returns |
|
212 | - * the validated value. |
|
213 | - * |
|
214 | - * @param mixed $value |
|
215 | - * @param string $type |
|
216 | - * @param array $params |
|
217 | - * @param bool $subval Whether this is a subvalue in a list |
|
218 | - * @throws Request_Exception |
|
219 | - * @return mixed |
|
220 | - */ |
|
210 | + /** |
|
211 | + * Validates the specified value using the validation type. Returns |
|
212 | + * the validated value. |
|
213 | + * |
|
214 | + * @param mixed $value |
|
215 | + * @param string $type |
|
216 | + * @param array $params |
|
217 | + * @param bool $subval Whether this is a subvalue in a list |
|
218 | + * @throws Request_Exception |
|
219 | + * @return mixed |
|
220 | + */ |
|
221 | 221 | protected function validateType($value, string $type, array $params, bool $subval) |
222 | 222 | { |
223 | 223 | $class = '\AppUtils\Request_Param_Validator_'.ucfirst($type); |
@@ -286,13 +286,13 @@ discard block |
||
286 | 286 | |
287 | 287 | protected $valueType = self::VALUE_TYPE_STRING; |
288 | 288 | |
289 | - /** |
|
290 | - * Sets the variable to contain a comma-separated list of integer IDs. |
|
291 | - * Example: <code>145,248,4556</code>. A single ID is also allowed, e.g. |
|
292 | - * <code>145</code>. |
|
293 | - * |
|
294 | - * @return Request_Param |
|
295 | - */ |
|
289 | + /** |
|
290 | + * Sets the variable to contain a comma-separated list of integer IDs. |
|
291 | + * Example: <code>145,248,4556</code>. A single ID is also allowed, e.g. |
|
292 | + * <code>145</code>. |
|
293 | + * |
|
294 | + * @return Request_Param |
|
295 | + */ |
|
296 | 296 | public function setIDList() |
297 | 297 | { |
298 | 298 | $this->valueType = self::VALUE_TYPE_LIST; |
@@ -302,13 +302,13 @@ discard block |
||
302 | 302 | return $this; |
303 | 303 | } |
304 | 304 | |
305 | - /** |
|
306 | - * Sets the variable to be an alias, as defined by the |
|
307 | - * {@link RegexHelper::REGEX_ALIAS} regular expression. |
|
308 | - * |
|
309 | - * @return Request_Param |
|
310 | - * @see RegexHelper::REGEX_ALIAS |
|
311 | - */ |
|
305 | + /** |
|
306 | + * Sets the variable to be an alias, as defined by the |
|
307 | + * {@link RegexHelper::REGEX_ALIAS} regular expression. |
|
308 | + * |
|
309 | + * @return Request_Param |
|
310 | + * @see RegexHelper::REGEX_ALIAS |
|
311 | + */ |
|
312 | 312 | public function setAlias() |
313 | 313 | { |
314 | 314 | return $this->setRegex(RegexHelper::REGEX_ALIAS); |
@@ -349,12 +349,12 @@ discard block |
||
349 | 349 | return $this->setValidation(self::VALIDATION_TYPE_ALPHA); |
350 | 350 | } |
351 | 351 | |
352 | - /** |
|
353 | - * Sets the parameter value as a string containing lowercase |
|
354 | - * and/or uppercase letters, as well as numbers. |
|
355 | - * |
|
356 | - * @return Request_Param |
|
357 | - */ |
|
352 | + /** |
|
353 | + * Sets the parameter value as a string containing lowercase |
|
354 | + * and/or uppercase letters, as well as numbers. |
|
355 | + * |
|
356 | + * @return Request_Param |
|
357 | + */ |
|
358 | 358 | public function setAlnum() |
359 | 359 | { |
360 | 360 | return $this->setValidation(self::VALIDATION_TYPE_ALNUM); |
@@ -387,17 +387,17 @@ discard block |
||
387 | 387 | ); |
388 | 388 | } |
389 | 389 | |
390 | - /** |
|
391 | - * Only available for array values: the parameter must be |
|
392 | - * an array value, and the array may only contain values |
|
393 | - * specified in the values array. |
|
394 | - * |
|
395 | - * Submitted values that are not in the allowed list of |
|
396 | - * values are stripped from the value. |
|
397 | - * |
|
398 | - * @param array $values List of allowed values |
|
399 | - * @return \AppUtils\Request_Param |
|
400 | - */ |
|
390 | + /** |
|
391 | + * Only available for array values: the parameter must be |
|
392 | + * an array value, and the array may only contain values |
|
393 | + * specified in the values array. |
|
394 | + * |
|
395 | + * Submitted values that are not in the allowed list of |
|
396 | + * values are stripped from the value. |
|
397 | + * |
|
398 | + * @param array $values List of allowed values |
|
399 | + * @return \AppUtils\Request_Param |
|
400 | + */ |
|
401 | 401 | public function setValuesList(array $values) |
402 | 402 | { |
403 | 403 | $this->setArray(); |
@@ -410,11 +410,11 @@ discard block |
||
410 | 410 | ); |
411 | 411 | } |
412 | 412 | |
413 | - /** |
|
414 | - * Whether the parameter is a list of values. |
|
415 | - * |
|
416 | - * @return bool |
|
417 | - */ |
|
413 | + /** |
|
414 | + * Whether the parameter is a list of values. |
|
415 | + * |
|
416 | + * @return bool |
|
417 | + */ |
|
418 | 418 | public function isList() : bool |
419 | 419 | { |
420 | 420 | return $this->valueType === self::VALUE_TYPE_LIST; |
@@ -425,53 +425,53 @@ discard block |
||
425 | 425 | return $this->setValidation(self::VALIDATION_TYPE_ARRAY); |
426 | 426 | } |
427 | 427 | |
428 | - /** |
|
429 | - * Specifies that a JSON-encoded string is expected. |
|
430 | - * |
|
431 | - * NOTE: Numbers or quoted strings are technically valid |
|
432 | - * JSON, but are not accepted, because it is assumed |
|
433 | - * at least an array or object are expected. |
|
434 | - * |
|
435 | - * @return \AppUtils\Request_Param |
|
436 | - */ |
|
428 | + /** |
|
429 | + * Specifies that a JSON-encoded string is expected. |
|
430 | + * |
|
431 | + * NOTE: Numbers or quoted strings are technically valid |
|
432 | + * JSON, but are not accepted, because it is assumed |
|
433 | + * at least an array or object are expected. |
|
434 | + * |
|
435 | + * @return \AppUtils\Request_Param |
|
436 | + */ |
|
437 | 437 | public function setJSON() : Request_Param |
438 | 438 | { |
439 | 439 | return $this->setValidation(self::VALIDATION_TYPE_JSON, array('arrays' => true)); |
440 | 440 | } |
441 | 441 | |
442 | - /** |
|
443 | - * Like {@link Request_Param::setJSON()}, but accepts |
|
444 | - * only JSON objects. Arrays will not be accepted. |
|
445 | - * |
|
446 | - * @return \AppUtils\Request_Param |
|
447 | - */ |
|
442 | + /** |
|
443 | + * Like {@link Request_Param::setJSON()}, but accepts |
|
444 | + * only JSON objects. Arrays will not be accepted. |
|
445 | + * |
|
446 | + * @return \AppUtils\Request_Param |
|
447 | + */ |
|
448 | 448 | public function setJSONObject() : Request_Param |
449 | 449 | { |
450 | 450 | return $this->setValidation(self::VALIDATION_TYPE_JSON, array('arrays' => false)); |
451 | 451 | } |
452 | 452 | |
453 | - /** |
|
454 | - * The parameter is a string boolean representation. This means |
|
455 | - * it can be any of the following: "yes", "true", "no", "false". |
|
456 | - * The value is automatically converted to a boolean when retrieving |
|
457 | - * the parameter. |
|
458 | - * |
|
459 | - * @return Request_Param |
|
460 | - */ |
|
453 | + /** |
|
454 | + * The parameter is a string boolean representation. This means |
|
455 | + * it can be any of the following: "yes", "true", "no", "false". |
|
456 | + * The value is automatically converted to a boolean when retrieving |
|
457 | + * the parameter. |
|
458 | + * |
|
459 | + * @return Request_Param |
|
460 | + */ |
|
461 | 461 | public function setBoolean() : Request_Param |
462 | 462 | { |
463 | 463 | return $this->addClassFilter('Boolean'); |
464 | 464 | } |
465 | 465 | |
466 | - /** |
|
467 | - * Validates the request parameter as an MD5 string, |
|
468 | - * so that only values resembling md5 values are accepted. |
|
469 | - * |
|
470 | - * NOTE: This can only guarantee the format, not whether |
|
471 | - * it is an actual valid hash of something. |
|
472 | - * |
|
473 | - * @return \AppUtils\Request_Param |
|
474 | - */ |
|
466 | + /** |
|
467 | + * Validates the request parameter as an MD5 string, |
|
468 | + * so that only values resembling md5 values are accepted. |
|
469 | + * |
|
470 | + * NOTE: This can only guarantee the format, not whether |
|
471 | + * it is an actual valid hash of something. |
|
472 | + * |
|
473 | + * @return \AppUtils\Request_Param |
|
474 | + */ |
|
475 | 475 | public function setMD5() : Request_Param |
476 | 476 | { |
477 | 477 | return $this->setRegex(RegexHelper::REGEX_MD5); |
@@ -513,14 +513,14 @@ discard block |
||
513 | 513 | return $this; |
514 | 514 | } |
515 | 515 | |
516 | - /** |
|
517 | - * Retrieves the value of the request parameter, |
|
518 | - * applying all filters (if any) and validation |
|
519 | - * (if any). |
|
520 | - * |
|
521 | - * @param mixed $default |
|
522 | - * @return mixed |
|
523 | - */ |
|
516 | + /** |
|
517 | + * Retrieves the value of the request parameter, |
|
518 | + * applying all filters (if any) and validation |
|
519 | + * (if any). |
|
520 | + * |
|
521 | + * @param mixed $default |
|
522 | + * @return mixed |
|
523 | + */ |
|
524 | 524 | public function get($default=null) |
525 | 525 | { |
526 | 526 | $value = $this->request->getParam($this->paramName); |
@@ -531,14 +531,14 @@ discard block |
||
531 | 531 | return $this->validate($default); |
532 | 532 | } |
533 | 533 | |
534 | - /** |
|
535 | - * Filters the specified value by going through all available |
|
536 | - * filters, if any. If none have been set, the value is simply |
|
537 | - * passed through. |
|
538 | - * |
|
539 | - * @param mixed $value |
|
540 | - * @return mixed |
|
541 | - */ |
|
534 | + /** |
|
535 | + * Filters the specified value by going through all available |
|
536 | + * filters, if any. If none have been set, the value is simply |
|
537 | + * passed through. |
|
538 | + * |
|
539 | + * @param mixed $value |
|
540 | + * @return mixed |
|
541 | + */ |
|
542 | 542 | protected function filter($value) |
543 | 543 | { |
544 | 544 | $total = count($this->filters); |
@@ -608,12 +608,12 @@ discard block |
||
608 | 608 | return $this; |
609 | 609 | } |
610 | 610 | |
611 | - /** |
|
612 | - * Adds a filter that trims whitespace from the request |
|
613 | - * parameter using the PHP <code>trim</code> function. |
|
614 | - * |
|
615 | - * @return \AppUtils\Request_Param |
|
616 | - */ |
|
611 | + /** |
|
612 | + * Adds a filter that trims whitespace from the request |
|
613 | + * parameter using the PHP <code>trim</code> function. |
|
614 | + * |
|
615 | + * @return \AppUtils\Request_Param |
|
616 | + */ |
|
617 | 617 | public function addFilterTrim() : Request_Param |
618 | 618 | { |
619 | 619 | // to guarantee we only work with strings |
@@ -622,13 +622,13 @@ discard block |
||
622 | 622 | return $this->addCallbackFilter('trim'); |
623 | 623 | } |
624 | 624 | |
625 | - /** |
|
626 | - * Converts the value to a string, even if it is not |
|
627 | - * a string value. Complex types like arrays and objects |
|
628 | - * are converted to an empty string. |
|
629 | - * |
|
630 | - * @return \AppUtils\Request_Param |
|
631 | - */ |
|
625 | + /** |
|
626 | + * Converts the value to a string, even if it is not |
|
627 | + * a string value. Complex types like arrays and objects |
|
628 | + * are converted to an empty string. |
|
629 | + * |
|
630 | + * @return \AppUtils\Request_Param |
|
631 | + */ |
|
632 | 632 | public function addStringFilter() : Request_Param |
633 | 633 | { |
634 | 634 | return $this->addClassFilter('String'); |
@@ -678,12 +678,12 @@ discard block |
||
678 | 678 | return $this->addCallbackFilter('strip_tags', array($allowedTags)); |
679 | 679 | } |
680 | 680 | |
681 | - /** |
|
682 | - * Adds a filter that strips all whitespace from the |
|
683 | - * request parameter, from spaces to tabs and newlines. |
|
684 | - * |
|
685 | - * @return \AppUtils\Request_Param |
|
686 | - */ |
|
681 | + /** |
|
682 | + * Adds a filter that strips all whitespace from the |
|
683 | + * request parameter, from spaces to tabs and newlines. |
|
684 | + * |
|
685 | + * @return \AppUtils\Request_Param |
|
686 | + */ |
|
687 | 687 | public function addStripWhitespaceFilter() : Request_Param |
688 | 688 | { |
689 | 689 | // to ensure we only work with strings. |
@@ -692,14 +692,14 @@ discard block |
||
692 | 692 | return $this->addClassFilter('StripWhitespace'); |
693 | 693 | } |
694 | 694 | |
695 | - /** |
|
696 | - * Adds a filter that transforms comma separated values |
|
697 | - * into an array of values. |
|
698 | - * |
|
699 | - * @param bool $trimEntries Trim whitespace from each entry? |
|
700 | - * @param bool $stripEmptyEntries Remove empty entries from the array? |
|
701 | - * @return \AppUtils\Request_Param |
|
702 | - */ |
|
695 | + /** |
|
696 | + * Adds a filter that transforms comma separated values |
|
697 | + * into an array of values. |
|
698 | + * |
|
699 | + * @param bool $trimEntries Trim whitespace from each entry? |
|
700 | + * @param bool $stripEmptyEntries Remove empty entries from the array? |
|
701 | + * @return \AppUtils\Request_Param |
|
702 | + */ |
|
703 | 703 | public function addCommaSeparatedFilter(bool $trimEntries=true, bool $stripEmptyEntries=true) : Request_Param |
704 | 704 | { |
705 | 705 | $this->setArray(); |
@@ -724,12 +724,12 @@ discard block |
||
724 | 724 | ); |
725 | 725 | } |
726 | 726 | |
727 | - /** |
|
728 | - * Adds a filter that encodes all HTML special characters |
|
729 | - * using the PHP <code>htmlspecialchars</code> function. |
|
730 | - * |
|
731 | - * @return \AppUtils\Request_Param |
|
732 | - */ |
|
727 | + /** |
|
728 | + * Adds a filter that encodes all HTML special characters |
|
729 | + * using the PHP <code>htmlspecialchars</code> function. |
|
730 | + * |
|
731 | + * @return \AppUtils\Request_Param |
|
732 | + */ |
|
733 | 733 | public function addHTMLSpecialcharsFilter() : Request_Param |
734 | 734 | { |
735 | 735 | return $this->addCallbackFilter('htmlspecialchars', array(ENT_QUOTES, 'UTF-8')); |
@@ -742,14 +742,14 @@ discard block |
||
742 | 742 | |
743 | 743 | protected $required = false; |
744 | 744 | |
745 | - /** |
|
746 | - * Marks this request parameter as required. To use this feature, |
|
747 | - * you have to call the request's {@link Request::validate()} |
|
748 | - * method. |
|
749 | - * |
|
750 | - * @return Request_Param |
|
751 | - * @see Request::validate() |
|
752 | - */ |
|
745 | + /** |
|
746 | + * Marks this request parameter as required. To use this feature, |
|
747 | + * you have to call the request's {@link Request::validate()} |
|
748 | + * method. |
|
749 | + * |
|
750 | + * @return Request_Param |
|
751 | + * @see Request::validate() |
|
752 | + */ |
|
753 | 753 | public function makeRequired() : Request_Param |
754 | 754 | { |
755 | 755 | $this->required = true; |