Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/http-foundation/ParameterBag.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 1fec387a4317 |
children | af1871eacc83 |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
24 protected $parameters; | 24 protected $parameters; |
25 | 25 |
26 /** | 26 /** |
27 * @param array $parameters An array of parameters | 27 * @param array $parameters An array of parameters |
28 */ | 28 */ |
29 public function __construct(array $parameters = array()) | 29 public function __construct(array $parameters = []) |
30 { | 30 { |
31 $this->parameters = $parameters; | 31 $this->parameters = $parameters; |
32 } | 32 } |
33 | 33 |
34 /** | 34 /** |
54 /** | 54 /** |
55 * Replaces the current parameters by a new set. | 55 * Replaces the current parameters by a new set. |
56 * | 56 * |
57 * @param array $parameters An array of parameters | 57 * @param array $parameters An array of parameters |
58 */ | 58 */ |
59 public function replace(array $parameters = array()) | 59 public function replace(array $parameters = []) |
60 { | 60 { |
61 $this->parameters = $parameters; | 61 $this->parameters = $parameters; |
62 } | 62 } |
63 | 63 |
64 /** | 64 /** |
65 * Adds parameters. | 65 * Adds parameters. |
66 * | 66 * |
67 * @param array $parameters An array of parameters | 67 * @param array $parameters An array of parameters |
68 */ | 68 */ |
69 public function add(array $parameters = array()) | 69 public function add(array $parameters = []) |
70 { | 70 { |
71 $this->parameters = array_replace($this->parameters, $parameters); | 71 $this->parameters = array_replace($this->parameters, $parameters); |
72 } | 72 } |
73 | 73 |
74 /** | 74 /** |
152 * @return string The filtered value | 152 * @return string The filtered value |
153 */ | 153 */ |
154 public function getDigits($key, $default = '') | 154 public function getDigits($key, $default = '') |
155 { | 155 { |
156 // we need to remove - and + because they're allowed in the filter | 156 // we need to remove - and + because they're allowed in the filter |
157 return str_replace(array('-', '+'), '', $this->filter($key, $default, FILTER_SANITIZE_NUMBER_INT)); | 157 return str_replace(['-', '+'], '', $this->filter($key, $default, FILTER_SANITIZE_NUMBER_INT)); |
158 } | 158 } |
159 | 159 |
160 /** | 160 /** |
161 * Returns the parameter value converted to integer. | 161 * Returns the parameter value converted to integer. |
162 * | 162 * |
172 | 172 |
173 /** | 173 /** |
174 * Returns the parameter value converted to boolean. | 174 * Returns the parameter value converted to boolean. |
175 * | 175 * |
176 * @param string $key The parameter key | 176 * @param string $key The parameter key |
177 * @param mixed $default The default value if the parameter key does not exist | 177 * @param bool $default The default value if the parameter key does not exist |
178 * | 178 * |
179 * @return bool The filtered value | 179 * @return bool The filtered value |
180 */ | 180 */ |
181 public function getBoolean($key, $default = false) | 181 public function getBoolean($key, $default = false) |
182 { | 182 { |
193 * | 193 * |
194 * @see http://php.net/manual/en/function.filter-var.php | 194 * @see http://php.net/manual/en/function.filter-var.php |
195 * | 195 * |
196 * @return mixed | 196 * @return mixed |
197 */ | 197 */ |
198 public function filter($key, $default = null, $filter = FILTER_DEFAULT, $options = array()) | 198 public function filter($key, $default = null, $filter = FILTER_DEFAULT, $options = []) |
199 { | 199 { |
200 $value = $this->get($key, $default); | 200 $value = $this->get($key, $default); |
201 | 201 |
202 // Always turn $options into an array - this allows filter_var option shortcuts. | 202 // Always turn $options into an array - this allows filter_var option shortcuts. |
203 if (!is_array($options) && $options) { | 203 if (!\is_array($options) && $options) { |
204 $options = array('flags' => $options); | 204 $options = ['flags' => $options]; |
205 } | 205 } |
206 | 206 |
207 // Add a convenience check for arrays. | 207 // Add a convenience check for arrays. |
208 if (is_array($value) && !isset($options['flags'])) { | 208 if (\is_array($value) && !isset($options['flags'])) { |
209 $options['flags'] = FILTER_REQUIRE_ARRAY; | 209 $options['flags'] = FILTER_REQUIRE_ARRAY; |
210 } | 210 } |
211 | 211 |
212 return filter_var($value, $filter, $options); | 212 return filter_var($value, $filter, $options); |
213 } | 213 } |
227 * | 227 * |
228 * @return int The number of parameters | 228 * @return int The number of parameters |
229 */ | 229 */ |
230 public function count() | 230 public function count() |
231 { | 231 { |
232 return count($this->parameters); | 232 return \count($this->parameters); |
233 } | 233 } |
234 } | 234 } |