@@ -26,18 +26,18 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | trait Traits_Optionable |
| 28 | 28 | { |
| 29 | - /** |
|
| 30 | - * @var array |
|
| 31 | - */ |
|
| 29 | + /** |
|
| 30 | + * @var array |
|
| 31 | + */ |
|
| 32 | 32 | protected $options; |
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Sets an option to the specified value. This can be any |
|
| 36 | - * kind of variable type, including objects, as needed. |
|
| 37 | - * |
|
| 38 | - * @param string $name |
|
| 39 | - * @param mixed $value |
|
| 40 | - */ |
|
| 34 | + /** |
|
| 35 | + * Sets an option to the specified value. This can be any |
|
| 36 | + * kind of variable type, including objects, as needed. |
|
| 37 | + * |
|
| 38 | + * @param string $name |
|
| 39 | + * @param mixed $value |
|
| 40 | + */ |
|
| 41 | 41 | public function setOption(string $name, $value) |
| 42 | 42 | { |
| 43 | 43 | if(!isset($this->options)) { |
@@ -48,12 +48,12 @@ discard block |
||
| 48 | 48 | return $this; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * Sets a collection of options at once, from an |
|
| 53 | - * associative array. |
|
| 54 | - * |
|
| 55 | - * @param array $options |
|
| 56 | - */ |
|
| 51 | + /** |
|
| 52 | + * Sets a collection of options at once, from an |
|
| 53 | + * associative array. |
|
| 54 | + * |
|
| 55 | + * @param array $options |
|
| 56 | + */ |
|
| 57 | 57 | public function setOptions(array $options) |
| 58 | 58 | { |
| 59 | 59 | foreach($options as $name => $value) { |
@@ -63,16 +63,16 @@ discard block |
||
| 63 | 63 | return $this; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * Retrieves an option's value. |
|
| 68 | - * |
|
| 69 | - * NOTE: Use the specialized type getters to ensure an option |
|
| 70 | - * contains the expected type (for ex. getArrayOption()). |
|
| 71 | - * |
|
| 72 | - * @param string $name |
|
| 73 | - * @param mixed $default The default value to return if the option does not exist. |
|
| 74 | - * @return mixed |
|
| 75 | - */ |
|
| 66 | + /** |
|
| 67 | + * Retrieves an option's value. |
|
| 68 | + * |
|
| 69 | + * NOTE: Use the specialized type getters to ensure an option |
|
| 70 | + * contains the expected type (for ex. getArrayOption()). |
|
| 71 | + * |
|
| 72 | + * @param string $name |
|
| 73 | + * @param mixed $default The default value to return if the option does not exist. |
|
| 74 | + * @return mixed |
|
| 75 | + */ |
|
| 76 | 76 | public function getOption(string $name, $default=null) |
| 77 | 77 | { |
| 78 | 78 | if(!isset($this->options)) { |
@@ -86,16 +86,16 @@ discard block |
||
| 86 | 86 | return $default; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - /** |
|
| 90 | - * Enforces that the option value is a string. Numbers are converted |
|
| 91 | - * to string, strings are passed through, and all other types will |
|
| 92 | - * return the default value. The default value is also returned if |
|
| 93 | - * the string is empty. |
|
| 94 | - * |
|
| 95 | - * @param string $name |
|
| 96 | - * @param string $default Used if the option does not exist, is invalid, or empty. |
|
| 97 | - * @return string |
|
| 98 | - */ |
|
| 89 | + /** |
|
| 90 | + * Enforces that the option value is a string. Numbers are converted |
|
| 91 | + * to string, strings are passed through, and all other types will |
|
| 92 | + * return the default value. The default value is also returned if |
|
| 93 | + * the string is empty. |
|
| 94 | + * |
|
| 95 | + * @param string $name |
|
| 96 | + * @param string $default Used if the option does not exist, is invalid, or empty. |
|
| 97 | + * @return string |
|
| 98 | + */ |
|
| 99 | 99 | public function getStringOption(string $name, string $default='') : string |
| 100 | 100 | { |
| 101 | 101 | $value = $this->getOption($name, false); |
@@ -107,15 +107,15 @@ discard block |
||
| 107 | 107 | return $default; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - /** |
|
| 111 | - * Treats the option value as a boolean value: will return |
|
| 112 | - * true if the value actually is a boolean true. |
|
| 113 | - * |
|
| 114 | - * NOTE: boolean string representations are not accepted. |
|
| 115 | - * |
|
| 116 | - * @param string $name |
|
| 117 | - * @return bool |
|
| 118 | - */ |
|
| 110 | + /** |
|
| 111 | + * Treats the option value as a boolean value: will return |
|
| 112 | + * true if the value actually is a boolean true. |
|
| 113 | + * |
|
| 114 | + * NOTE: boolean string representations are not accepted. |
|
| 115 | + * |
|
| 116 | + * @param string $name |
|
| 117 | + * @return bool |
|
| 118 | + */ |
|
| 119 | 119 | public function getBoolOption(string $name, bool $default=false) : bool |
| 120 | 120 | { |
| 121 | 121 | if($this->getOption($name) === true) { |
@@ -125,15 +125,15 @@ discard block |
||
| 125 | 125 | return $default; |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - /** |
|
| 129 | - * Treats the option value as an integer value: will return |
|
| 130 | - * valid integer values (also from integer strings), or the |
|
| 131 | - * default value otherwise. |
|
| 132 | - * |
|
| 133 | - * @param string $name |
|
| 134 | - * @param int $default |
|
| 135 | - * @return int |
|
| 136 | - */ |
|
| 128 | + /** |
|
| 129 | + * Treats the option value as an integer value: will return |
|
| 130 | + * valid integer values (also from integer strings), or the |
|
| 131 | + * default value otherwise. |
|
| 132 | + * |
|
| 133 | + * @param string $name |
|
| 134 | + * @param int $default |
|
| 135 | + * @return int |
|
| 136 | + */ |
|
| 137 | 137 | public function getIntOption(string $name, int $default=0) : int |
| 138 | 138 | { |
| 139 | 139 | $value = $this->getOption($name); |
@@ -144,14 +144,14 @@ discard block |
||
| 144 | 144 | return $default; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - /** |
|
| 148 | - * Treats an option as an array, and returns its value |
|
| 149 | - * only if it contains an array - otherwise, an empty |
|
| 150 | - * array is returned. |
|
| 151 | - * |
|
| 152 | - * @param string $name |
|
| 153 | - * @return array |
|
| 154 | - */ |
|
| 147 | + /** |
|
| 148 | + * Treats an option as an array, and returns its value |
|
| 149 | + * only if it contains an array - otherwise, an empty |
|
| 150 | + * array is returned. |
|
| 151 | + * |
|
| 152 | + * @param string $name |
|
| 153 | + * @return array |
|
| 154 | + */ |
|
| 155 | 155 | public function getArrayOption(string $name) : array |
| 156 | 156 | { |
| 157 | 157 | $val = $this->getOption($name); |
@@ -162,13 +162,13 @@ discard block |
||
| 162 | 162 | return array(); |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - /** |
|
| 166 | - * Checks whether the specified option exists - even |
|
| 167 | - * if it has a NULL value. |
|
| 168 | - * |
|
| 169 | - * @param string $name |
|
| 170 | - * @return bool |
|
| 171 | - */ |
|
| 165 | + /** |
|
| 166 | + * Checks whether the specified option exists - even |
|
| 167 | + * if it has a NULL value. |
|
| 168 | + * |
|
| 169 | + * @param string $name |
|
| 170 | + * @return bool |
|
| 171 | + */ |
|
| 172 | 172 | public function hasOption(string $name) : bool |
| 173 | 173 | { |
| 174 | 174 | if(!isset($this->options)) { |
@@ -178,10 +178,10 @@ discard block |
||
| 178 | 178 | return array_key_exists($name, $this->options); |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - /** |
|
| 182 | - * Returns all options in one associative array. |
|
| 183 | - * @return array |
|
| 184 | - */ |
|
| 181 | + /** |
|
| 182 | + * Returns all options in one associative array. |
|
| 183 | + * @return array |
|
| 184 | + */ |
|
| 185 | 185 | public function getOptions() : array |
| 186 | 186 | { |
| 187 | 187 | if(!isset($this->options)) { |
@@ -191,24 +191,24 @@ discard block |
||
| 191 | 191 | return $this->options; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - /** |
|
| 195 | - * Checks whether the option's value is the one specified. |
|
| 196 | - * |
|
| 197 | - * @param string $name |
|
| 198 | - * @param mixed $value |
|
| 199 | - * @return bool |
|
| 200 | - */ |
|
| 194 | + /** |
|
| 195 | + * Checks whether the option's value is the one specified. |
|
| 196 | + * |
|
| 197 | + * @param string $name |
|
| 198 | + * @param mixed $value |
|
| 199 | + * @return bool |
|
| 200 | + */ |
|
| 201 | 201 | public function isOption(string $name, $value) : bool |
| 202 | 202 | { |
| 203 | 203 | return $this->getOption($name) === $value; |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - /** |
|
| 207 | - * Retrieves the default available options as an |
|
| 208 | - * associative array with option name => value pairs. |
|
| 209 | - * |
|
| 210 | - * @return array |
|
| 211 | - */ |
|
| 206 | + /** |
|
| 207 | + * Retrieves the default available options as an |
|
| 208 | + * associative array with option name => value pairs. |
|
| 209 | + * |
|
| 210 | + * @return array |
|
| 211 | + */ |
|
| 212 | 212 | abstract public function getDefaultOptions() : array; |
| 213 | 213 | } |
| 214 | 214 | |
@@ -226,24 +226,24 @@ discard block |
||
| 226 | 226 | */ |
| 227 | 227 | interface Interface_Optionable |
| 228 | 228 | { |
| 229 | - /** |
|
| 230 | - * @param string $name |
|
| 231 | - * @param mixed $value |
|
| 232 | - * @return $this |
|
| 233 | - */ |
|
| 229 | + /** |
|
| 230 | + * @param string $name |
|
| 231 | + * @param mixed $value |
|
| 232 | + * @return $this |
|
| 233 | + */ |
|
| 234 | 234 | function setOption(string $name, $value); |
| 235 | 235 | |
| 236 | - /** |
|
| 237 | - * @param string $name |
|
| 238 | - * @param mixed $default |
|
| 239 | - * @return $this |
|
| 240 | - */ |
|
| 236 | + /** |
|
| 237 | + * @param string $name |
|
| 238 | + * @param mixed $default |
|
| 239 | + * @return $this |
|
| 240 | + */ |
|
| 241 | 241 | function getOption(string $name, $default=null); |
| 242 | 242 | |
| 243 | - /** |
|
| 244 | - * @param array $options |
|
| 245 | - * @return $this |
|
| 246 | - */ |
|
| 243 | + /** |
|
| 244 | + * @param array $options |
|
| 245 | + * @return $this |
|
| 246 | + */ |
|
| 247 | 247 | function setOptions(array $options); |
| 248 | 248 | function getOptions() : array; |
| 249 | 249 | function isOption(string $name, $value) : bool; |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | public function setOption(string $name, $value) |
| 42 | 42 | { |
| 43 | - if(!isset($this->options)) { |
|
| 43 | + if (!isset($this->options)) { |
|
| 44 | 44 | $this->options = $this->getDefaultOptions(); |
| 45 | 45 | } |
| 46 | 46 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | public function setOptions(array $options) |
| 58 | 58 | { |
| 59 | - foreach($options as $name => $value) { |
|
| 59 | + foreach ($options as $name => $value) { |
|
| 60 | 60 | $this->setOption($name, $value); |
| 61 | 61 | } |
| 62 | 62 | |
@@ -73,13 +73,13 @@ discard block |
||
| 73 | 73 | * @param mixed $default The default value to return if the option does not exist. |
| 74 | 74 | * @return mixed |
| 75 | 75 | */ |
| 76 | - public function getOption(string $name, $default=null) |
|
| 76 | + public function getOption(string $name, $default = null) |
|
| 77 | 77 | { |
| 78 | - if(!isset($this->options)) { |
|
| 78 | + if (!isset($this->options)) { |
|
| 79 | 79 | $this->options = $this->getDefaultOptions(); |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - if(isset($this->options[$name])) { |
|
| 82 | + if (isset($this->options[$name])) { |
|
| 83 | 83 | return $this->options[$name]; |
| 84 | 84 | } |
| 85 | 85 | |
@@ -96,11 +96,11 @@ discard block |
||
| 96 | 96 | * @param string $default Used if the option does not exist, is invalid, or empty. |
| 97 | 97 | * @return string |
| 98 | 98 | */ |
| 99 | - public function getStringOption(string $name, string $default='') : string |
|
| 99 | + public function getStringOption(string $name, string $default = '') : string |
|
| 100 | 100 | { |
| 101 | 101 | $value = $this->getOption($name, false); |
| 102 | 102 | |
| 103 | - if((is_string($value) || is_numeric($value)) && !empty($value)) { |
|
| 103 | + if ((is_string($value) || is_numeric($value)) && !empty($value)) { |
|
| 104 | 104 | return (string)$value; |
| 105 | 105 | } |
| 106 | 106 | |
@@ -116,9 +116,9 @@ discard block |
||
| 116 | 116 | * @param string $name |
| 117 | 117 | * @return bool |
| 118 | 118 | */ |
| 119 | - public function getBoolOption(string $name, bool $default=false) : bool |
|
| 119 | + public function getBoolOption(string $name, bool $default = false) : bool |
|
| 120 | 120 | { |
| 121 | - if($this->getOption($name) === true) { |
|
| 121 | + if ($this->getOption($name) === true) { |
|
| 122 | 122 | return true; |
| 123 | 123 | } |
| 124 | 124 | |
@@ -134,10 +134,10 @@ discard block |
||
| 134 | 134 | * @param int $default |
| 135 | 135 | * @return int |
| 136 | 136 | */ |
| 137 | - public function getIntOption(string $name, int $default=0) : int |
|
| 137 | + public function getIntOption(string $name, int $default = 0) : int |
|
| 138 | 138 | { |
| 139 | 139 | $value = $this->getOption($name); |
| 140 | - if(ConvertHelper::isInteger($value)) { |
|
| 140 | + if (ConvertHelper::isInteger($value)) { |
|
| 141 | 141 | return (int)$value; |
| 142 | 142 | } |
| 143 | 143 | |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | public function getArrayOption(string $name) : array |
| 156 | 156 | { |
| 157 | 157 | $val = $this->getOption($name); |
| 158 | - if(is_array($val)) { |
|
| 158 | + if (is_array($val)) { |
|
| 159 | 159 | return $val; |
| 160 | 160 | } |
| 161 | 161 | |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | */ |
| 172 | 172 | public function hasOption(string $name) : bool |
| 173 | 173 | { |
| 174 | - if(!isset($this->options)) { |
|
| 174 | + if (!isset($this->options)) { |
|
| 175 | 175 | $this->options = $this->getDefaultOptions(); |
| 176 | 176 | } |
| 177 | 177 | |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | public function getOptions() : array |
| 186 | 186 | { |
| 187 | - if(!isset($this->options)) { |
|
| 187 | + if (!isset($this->options)) { |
|
| 188 | 188 | $this->options = $this->getDefaultOptions(); |
| 189 | 189 | } |
| 190 | 190 | |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | * @param mixed $default |
| 239 | 239 | * @return $this |
| 240 | 240 | */ |
| 241 | - function getOption(string $name, $default=null); |
|
| 241 | + function getOption(string $name, $default = null); |
|
| 242 | 242 | |
| 243 | 243 | /** |
| 244 | 244 | * @param array $options |
@@ -83,12 +83,12 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | public function addFile(string $varName, string $fileName, string $content, string $contentType = '', string $encoding = '') : RequestHelper_Boundaries |
| 85 | 85 | { |
| 86 | - if(empty($contentType)) |
|
| 86 | + if (empty($contentType)) |
|
| 87 | 87 | { |
| 88 | 88 | $contentType = (string)FileHelper::detectMimeType($fileName); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - if(empty($encoding)) |
|
| 91 | + if (empty($encoding)) |
|
| 92 | 92 | { |
| 93 | 93 | $encoding = RequestHelper::ENCODING_UTF8; |
| 94 | 94 | $content = ConvertHelper::string2utf8($content); |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | */ |
| 154 | 154 | public function render() : string |
| 155 | 155 | { |
| 156 | - if(empty($this->boundaries)) |
|
| 156 | + if (empty($this->boundaries)) |
|
| 157 | 157 | { |
| 158 | 158 | throw new RequestHelper_Exception( |
| 159 | 159 | 'No mime boundaries added', |
@@ -164,13 +164,13 @@ discard block |
||
| 164 | 164 | |
| 165 | 165 | $result = ''; |
| 166 | 166 | |
| 167 | - foreach($this->boundaries as $boundary) |
|
| 167 | + foreach ($this->boundaries as $boundary) |
|
| 168 | 168 | { |
| 169 | 169 | $result .= $boundary->render(); |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - $result .= "--" . $this->getMimeBoundary() . "--" . |
|
| 173 | - $this->getEOL() . $this->getEOL(); // always finish with two eol's!! |
|
| 172 | + $result .= "--".$this->getMimeBoundary()."--". |
|
| 173 | + $this->getEOL().$this->getEOL(); // always finish with two eol's!! |
|
| 174 | 174 | |
| 175 | 175 | return $result; |
| 176 | 176 | } |
@@ -22,19 +22,19 @@ discard block |
||
| 22 | 22 | { |
| 23 | 23 | const ERROR_NO_BOUNDARIES_SPECIFIED = 44401; |
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @var RequestHelper |
|
| 27 | - */ |
|
| 25 | + /** |
|
| 26 | + * @var RequestHelper |
|
| 27 | + */ |
|
| 28 | 28 | protected $helper; |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * @var RequestHelper_Boundaries_Boundary[] |
|
| 32 | - */ |
|
| 30 | + /** |
|
| 31 | + * @var RequestHelper_Boundaries_Boundary[] |
|
| 32 | + */ |
|
| 33 | 33 | protected $boundaries = array(); |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @var integer |
|
| 37 | - */ |
|
| 35 | + /** |
|
| 36 | + * @var integer |
|
| 37 | + */ |
|
| 38 | 38 | protected $contentLength = 0; |
| 39 | 39 | |
| 40 | 40 | public function __construct(RequestHelper $helper) |
@@ -42,31 +42,31 @@ discard block |
||
| 42 | 42 | $this->helper = $helper; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Retrieves the string that is used to separate mime boundaries in the body. |
|
| 47 | - * |
|
| 48 | - * @return string |
|
| 49 | - */ |
|
| 45 | + /** |
|
| 46 | + * Retrieves the string that is used to separate mime boundaries in the body. |
|
| 47 | + * |
|
| 48 | + * @return string |
|
| 49 | + */ |
|
| 50 | 50 | public function getMimeBoundary() : string |
| 51 | 51 | { |
| 52 | 52 | return $this->helper->getMimeBoundary(); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Retrieves the end of line character(s) used in the body. |
|
| 57 | - * |
|
| 58 | - * @return string |
|
| 59 | - */ |
|
| 55 | + /** |
|
| 56 | + * Retrieves the end of line character(s) used in the body. |
|
| 57 | + * |
|
| 58 | + * @return string |
|
| 59 | + */ |
|
| 60 | 60 | public function getEOL() : string |
| 61 | 61 | { |
| 62 | 62 | return $this->helper->getEOL(); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * Retrieves the total content length of all boundary contents. |
|
| 67 | - * |
|
| 68 | - * @return int |
|
| 69 | - */ |
|
| 65 | + /** |
|
| 66 | + * Retrieves the total content length of all boundary contents. |
|
| 67 | + * |
|
| 68 | + * @return int |
|
| 69 | + */ |
|
| 70 | 70 | public function getContentLength() : int |
| 71 | 71 | { |
| 72 | 72 | // this must use strlen, and not mb_strlen: the content length |
@@ -75,15 +75,15 @@ discard block |
||
| 75 | 75 | return strlen($this->render()); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * Adds a file to be sent with the request. |
|
| 80 | - * |
|
| 81 | - * @param string $varName The variable name to send the file in |
|
| 82 | - * @param string $fileName The name of the file as it should be received at the destination |
|
| 83 | - * @param string $content The raw content of the file |
|
| 84 | - * @param string $contentType The content type, use the constants to specify this |
|
| 85 | - * @param string $encoding The encoding of the file, use the constants to specify this |
|
| 86 | - */ |
|
| 78 | + /** |
|
| 79 | + * Adds a file to be sent with the request. |
|
| 80 | + * |
|
| 81 | + * @param string $varName The variable name to send the file in |
|
| 82 | + * @param string $fileName The name of the file as it should be received at the destination |
|
| 83 | + * @param string $content The raw content of the file |
|
| 84 | + * @param string $contentType The content type, use the constants to specify this |
|
| 85 | + * @param string $encoding The encoding of the file, use the constants to specify this |
|
| 86 | + */ |
|
| 87 | 87 | public function addFile(string $varName, string $fileName, string $content, string $contentType = '', string $encoding = '') : RequestHelper_Boundaries |
| 88 | 88 | { |
| 89 | 89 | if(empty($contentType)) |
@@ -107,13 +107,13 @@ discard block |
||
| 107 | 107 | return $this->addBoundary($boundary); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - /** |
|
| 111 | - * Adds arbitrary content. |
|
| 112 | - * |
|
| 113 | - * @param string $varName |
|
| 114 | - * @param string $content |
|
| 115 | - * @param string $contentType |
|
| 116 | - */ |
|
| 110 | + /** |
|
| 111 | + * Adds arbitrary content. |
|
| 112 | + * |
|
| 113 | + * @param string $varName |
|
| 114 | + * @param string $content |
|
| 115 | + * @param string $contentType |
|
| 116 | + */ |
|
| 117 | 117 | public function addContent(string $varName, string $content, string $contentType) : RequestHelper_Boundaries |
| 118 | 118 | { |
| 119 | 119 | $content = ConvertHelper::string2utf8($content); |
@@ -127,13 +127,13 @@ discard block |
||
| 127 | 127 | return $this->addBoundary($boundary); |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - /** |
|
| 131 | - * Adds a variable to be sent with the request. If it |
|
| 132 | - * already exists, its value is overwritten. |
|
| 133 | - * |
|
| 134 | - * @param string $name |
|
| 135 | - * @param string $value |
|
| 136 | - */ |
|
| 130 | + /** |
|
| 131 | + * Adds a variable to be sent with the request. If it |
|
| 132 | + * already exists, its value is overwritten. |
|
| 133 | + * |
|
| 134 | + * @param string $name |
|
| 135 | + * @param string $value |
|
| 136 | + */ |
|
| 137 | 137 | public function addVariable(string $name, string $value) : RequestHelper_Boundaries |
| 138 | 138 | { |
| 139 | 139 | $boundary = $this->createBoundary($value) |
@@ -149,11 +149,11 @@ discard block |
||
| 149 | 149 | return $this; |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - /** |
|
| 153 | - * Renders the response body with all mime boundaries. |
|
| 154 | - * |
|
| 155 | - * @return string |
|
| 156 | - */ |
|
| 152 | + /** |
|
| 153 | + * Renders the response body with all mime boundaries. |
|
| 154 | + * |
|
| 155 | + * @return string |
|
| 156 | + */ |
|
| 157 | 157 | public function render() : string |
| 158 | 158 | { |
| 159 | 159 | if(empty($this->boundaries)) |
@@ -20,9 +20,9 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | class URLInfo_Highlighter |
| 22 | 22 | { |
| 23 | - /** |
|
| 24 | - * @var URLInfo |
|
| 25 | - */ |
|
| 23 | + /** |
|
| 24 | + * @var URLInfo |
|
| 25 | + */ |
|
| 26 | 26 | protected $info; |
| 27 | 27 | |
| 28 | 28 | public function __construct(URLInfo $info) |
@@ -158,13 +158,13 @@ discard block |
||
| 158 | 158 | ); |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - /** |
|
| 162 | - * Fetches all parameters in the URL, regardless of |
|
| 163 | - * whether parameter exclusion is enabled, so they |
|
| 164 | - * can be highlighted is need be. |
|
| 165 | - * |
|
| 166 | - * @return array |
|
| 167 | - */ |
|
| 161 | + /** |
|
| 162 | + * Fetches all parameters in the URL, regardless of |
|
| 163 | + * whether parameter exclusion is enabled, so they |
|
| 164 | + * can be highlighted is need be. |
|
| 165 | + * |
|
| 166 | + * @return array |
|
| 167 | + */ |
|
| 168 | 168 | protected function resolveParams() : array |
| 169 | 169 | { |
| 170 | 170 | $previous = $this->info->isParamExclusionEnabled(); |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | 'fragment' |
| 78 | 78 | ); |
| 79 | 79 | |
| 80 | - foreach($parts as $part) |
|
| 80 | + foreach ($parts as $part) |
|
| 81 | 81 | { |
| 82 | 82 | $method = 'render_'.$part; |
| 83 | 83 | $result[] = (string)$this->$method(); |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | |
| 89 | 89 | protected function render_scheme() : string |
| 90 | 90 | { |
| 91 | - if(!$this->info->hasScheme()) { |
|
| 91 | + if (!$this->info->hasScheme()) { |
|
| 92 | 92 | return ''; |
| 93 | 93 | } |
| 94 | 94 | |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | protected function render_username() : string |
| 105 | 105 | { |
| 106 | - if(!$this->info->hasUsername()) { |
|
| 106 | + if (!$this->info->hasUsername()) { |
|
| 107 | 107 | return ''; |
| 108 | 108 | } |
| 109 | 109 | |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | protected function render_host() : string |
| 121 | 121 | { |
| 122 | - if(!$this->info->hasHost()) { |
|
| 122 | + if (!$this->info->hasHost()) { |
|
| 123 | 123 | return ''; |
| 124 | 124 | } |
| 125 | 125 | |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | protected function render_port() : string |
| 133 | 133 | { |
| 134 | - if(!$this->info->hasPort()) { |
|
| 134 | + if (!$this->info->hasPort()) { |
|
| 135 | 135 | return ''; |
| 136 | 136 | } |
| 137 | 137 | |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | protected function render_path() : string |
| 146 | 146 | { |
| 147 | - if(!$this->info->hasPath()) { |
|
| 147 | + if (!$this->info->hasPath()) { |
|
| 148 | 148 | return ''; |
| 149 | 149 | } |
| 150 | 150 | |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | { |
| 170 | 170 | $previous = $this->info->isParamExclusionEnabled(); |
| 171 | 171 | |
| 172 | - if($previous) |
|
| 172 | + if ($previous) |
|
| 173 | 173 | { |
| 174 | 174 | $this->info->setParamExclusion(false); |
| 175 | 175 | } |
@@ -185,19 +185,19 @@ discard block |
||
| 185 | 185 | { |
| 186 | 186 | $params = $this->resolveParams(); |
| 187 | 187 | |
| 188 | - if(empty($params)) { |
|
| 188 | + if (empty($params)) { |
|
| 189 | 189 | return ''; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | $tokens = array(); |
| 193 | 193 | $excluded = array(); |
| 194 | 194 | |
| 195 | - if($this->info->isParamExclusionEnabled()) |
|
| 195 | + if ($this->info->isParamExclusionEnabled()) |
|
| 196 | 196 | { |
| 197 | 197 | $excluded = $this->info->getExcludedParams(); |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - foreach($params as $param => $value) |
|
| 200 | + foreach ($params as $param => $value) |
|
| 201 | 201 | { |
| 202 | 202 | $parts = sprintf( |
| 203 | 203 | '<span class="link-param-name">%s</span>'. |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | |
| 215 | 215 | $tag = $this->resolveTag($excluded, $param); |
| 216 | 216 | |
| 217 | - if(!empty($tag)) |
|
| 217 | + if (!empty($tag)) |
|
| 218 | 218 | { |
| 219 | 219 | $tokens[] = sprintf($tag, $parts); |
| 220 | 220 | } |
@@ -228,13 +228,13 @@ discard block |
||
| 228 | 228 | protected function resolveTag(array $excluded, string $paramName) : string |
| 229 | 229 | { |
| 230 | 230 | // regular, non-excluded parameter |
| 231 | - if(!isset($excluded[$paramName])) |
|
| 231 | + if (!isset($excluded[$paramName])) |
|
| 232 | 232 | { |
| 233 | 233 | return '<span class="link-param">%s</span>'; |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | // highlight excluded parameters is disabled, ignore this parameter |
| 237 | - if(!$this->info->isHighlightExcludeEnabled()) |
|
| 237 | + if (!$this->info->isHighlightExcludeEnabled()) |
|
| 238 | 238 | { |
| 239 | 239 | return ''; |
| 240 | 240 | } |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | |
| 251 | 251 | protected function render_fragment() : string |
| 252 | 252 | { |
| 253 | - if(!$this->info->hasFragment()) { |
|
| 253 | + if (!$this->info->hasFragment()) { |
|
| 254 | 254 | return ''; |
| 255 | 255 | } |
| 256 | 256 | |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | { |
| 266 | 266 | $cssFolder = realpath(__DIR__.'/../../css'); |
| 267 | 267 | |
| 268 | - if($cssFolder === false) { |
|
| 268 | + if ($cssFolder === false) { |
|
| 269 | 269 | throw new BaseException( |
| 270 | 270 | 'Cannot find package CSS folder.', |
| 271 | 271 | null, |
@@ -27,16 +27,16 @@ |
||
| 27 | 27 | |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * We parse the query string ourselves, because the PHP implementation |
|
| 32 | - * of parse_str has limitations that do not apply to query strings. This |
|
| 33 | - * is due to the fact that parse_str has to create PHP-compatible variable |
|
| 34 | - * names from the parameters. URL parameters simply allow way more things |
|
| 35 | - * than PHP variable names. |
|
| 36 | - * |
|
| 37 | - * @param string $queryString |
|
| 38 | - * @return array |
|
| 39 | - */ |
|
| 30 | + /** |
|
| 31 | + * We parse the query string ourselves, because the PHP implementation |
|
| 32 | + * of parse_str has limitations that do not apply to query strings. This |
|
| 33 | + * is due to the fact that parse_str has to create PHP-compatible variable |
|
| 34 | + * names from the parameters. URL parameters simply allow way more things |
|
| 35 | + * than PHP variable names. |
|
| 36 | + * |
|
| 37 | + * @param string $queryString |
|
| 38 | + * @return array |
|
| 39 | + */ |
|
| 40 | 40 | public function parse(string $queryString) : array |
| 41 | 41 | { |
| 42 | 42 | // allow HTML entities notation |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | $result = array(); |
| 48 | 48 | |
| 49 | - foreach($parts as $part) |
|
| 49 | + foreach ($parts as $part) |
|
| 50 | 50 | { |
| 51 | 51 | $tokens = explode('=', $part); |
| 52 | 52 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | $trimmed = trim($name); |
| 57 | 57 | |
| 58 | - if(empty($trimmed)) |
|
| 58 | + if (empty($trimmed)) |
|
| 59 | 59 | { |
| 60 | 60 | continue; |
| 61 | 61 | } |
@@ -39,42 +39,42 @@ discard block |
||
| 39 | 39 | const TYPE_PHONE = 'phone'; |
| 40 | 40 | const TYPE_URL = 'url'; |
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * The original URL that was passed to the constructor. |
|
| 44 | - * @var string |
|
| 45 | - */ |
|
| 42 | + /** |
|
| 43 | + * The original URL that was passed to the constructor. |
|
| 44 | + * @var string |
|
| 45 | + */ |
|
| 46 | 46 | protected $rawURL; |
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * @var array |
|
| 50 | - */ |
|
| 48 | + /** |
|
| 49 | + * @var array |
|
| 50 | + */ |
|
| 51 | 51 | protected $info; |
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * @var string[] |
|
| 55 | - */ |
|
| 53 | + /** |
|
| 54 | + * @var string[] |
|
| 55 | + */ |
|
| 56 | 56 | protected $excludedParams = array(); |
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * @var bool |
|
| 60 | - * @see URLInfo::setParamExclusion() |
|
| 61 | - */ |
|
| 58 | + /** |
|
| 59 | + * @var bool |
|
| 60 | + * @see URLInfo::setParamExclusion() |
|
| 61 | + */ |
|
| 62 | 62 | protected $paramExclusion = false; |
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * @var array |
|
| 66 | - * @see URLInfo::getTypeLabel() |
|
| 67 | - */ |
|
| 64 | + /** |
|
| 65 | + * @var array |
|
| 66 | + * @see URLInfo::getTypeLabel() |
|
| 67 | + */ |
|
| 68 | 68 | protected static $typeLabels; |
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * @var bool |
|
| 72 | - */ |
|
| 70 | + /** |
|
| 71 | + * @var bool |
|
| 72 | + */ |
|
| 73 | 73 | protected $highlightExcluded = false; |
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * @var array |
|
| 77 | - */ |
|
| 75 | + /** |
|
| 76 | + * @var array |
|
| 77 | + */ |
|
| 78 | 78 | protected $infoKeys = array( |
| 79 | 79 | 'scheme', |
| 80 | 80 | 'host', |
@@ -86,24 +86,24 @@ discard block |
||
| 86 | 86 | 'fragment' |
| 87 | 87 | ); |
| 88 | 88 | |
| 89 | - /** |
|
| 90 | - * @var string |
|
| 91 | - */ |
|
| 89 | + /** |
|
| 90 | + * @var string |
|
| 91 | + */ |
|
| 92 | 92 | protected $url; |
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * @var URLInfo_Parser |
|
| 96 | - */ |
|
| 94 | + /** |
|
| 95 | + * @var URLInfo_Parser |
|
| 96 | + */ |
|
| 97 | 97 | protected $parser; |
| 98 | 98 | |
| 99 | - /** |
|
| 100 | - * @var URLInfo_Normalizer |
|
| 101 | - */ |
|
| 99 | + /** |
|
| 100 | + * @var URLInfo_Normalizer |
|
| 101 | + */ |
|
| 102 | 102 | protected $normalizer; |
| 103 | 103 | |
| 104 | - /** |
|
| 105 | - * @var bool |
|
| 106 | - */ |
|
| 104 | + /** |
|
| 105 | + * @var bool |
|
| 106 | + */ |
|
| 107 | 107 | protected $encodeUTFChars = false; |
| 108 | 108 | |
| 109 | 109 | public function __construct(string $url) |
@@ -120,14 +120,14 @@ discard block |
||
| 120 | 120 | $this->info = $this->parser->getInfo(); |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - /** |
|
| 124 | - * Whether to URL encode any non-encoded UTF8 characters in the URL. |
|
| 125 | - * Default is to leave them as-is for better readability, since |
|
| 126 | - * browsers handle this well. |
|
| 127 | - * |
|
| 128 | - * @param bool $enabled |
|
| 129 | - * @return URLInfo |
|
| 130 | - */ |
|
| 123 | + /** |
|
| 124 | + * Whether to URL encode any non-encoded UTF8 characters in the URL. |
|
| 125 | + * Default is to leave them as-is for better readability, since |
|
| 126 | + * browsers handle this well. |
|
| 127 | + * |
|
| 128 | + * @param bool $enabled |
|
| 129 | + * @return URLInfo |
|
| 130 | + */ |
|
| 131 | 131 | public function setUTFEncoding(bool $enabled=true) : URLInfo |
| 132 | 132 | { |
| 133 | 133 | if($this->encodeUTFChars !== $enabled) |
@@ -144,13 +144,13 @@ discard block |
||
| 144 | 144 | return $this->encodeUTFChars; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - /** |
|
| 148 | - * Filters an URL: removes control characters and the |
|
| 149 | - * like to have a clean URL to work with. |
|
| 150 | - * |
|
| 151 | - * @param string $url |
|
| 152 | - * @return string |
|
| 153 | - */ |
|
| 147 | + /** |
|
| 148 | + * Filters an URL: removes control characters and the |
|
| 149 | + * like to have a clean URL to work with. |
|
| 150 | + * |
|
| 151 | + * @param string $url |
|
| 152 | + * @return string |
|
| 153 | + */ |
|
| 154 | 154 | public static function filterURL(string $url) |
| 155 | 155 | { |
| 156 | 156 | return URLInfo_Filter::filter($url); |
@@ -180,12 +180,12 @@ discard block |
||
| 180 | 180 | return $this->info['type'] === self::TYPE_PHONE; |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - /** |
|
| 184 | - * Whether the URL is a regular URL, not one of the |
|
| 185 | - * other types like a phone number or email address. |
|
| 186 | - * |
|
| 187 | - * @return bool |
|
| 188 | - */ |
|
| 183 | + /** |
|
| 184 | + * Whether the URL is a regular URL, not one of the |
|
| 185 | + * other types like a phone number or email address. |
|
| 186 | + * |
|
| 187 | + * @return bool |
|
| 188 | + */ |
|
| 189 | 189 | public function isURL() : bool |
| 190 | 190 | { |
| 191 | 191 | $host = $this->getHost(); |
@@ -197,20 +197,20 @@ discard block |
||
| 197 | 197 | return $this->parser->isValid(); |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - /** |
|
| 201 | - * Retrieves the host name, or an empty string if none is present. |
|
| 202 | - * |
|
| 203 | - * @return string |
|
| 204 | - */ |
|
| 200 | + /** |
|
| 201 | + * Retrieves the host name, or an empty string if none is present. |
|
| 202 | + * |
|
| 203 | + * @return string |
|
| 204 | + */ |
|
| 205 | 205 | public function getHost() : string |
| 206 | 206 | { |
| 207 | 207 | return $this->getInfoKey('host'); |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - /** |
|
| 211 | - * Retrieves the path, or an empty string if none is present. |
|
| 212 | - * @return string |
|
| 213 | - */ |
|
| 210 | + /** |
|
| 211 | + * Retrieves the path, or an empty string if none is present. |
|
| 212 | + * @return string |
|
| 213 | + */ |
|
| 214 | 214 | public function getPath() : string |
| 215 | 215 | { |
| 216 | 216 | return $this->getInfoKey('path'); |
@@ -226,10 +226,10 @@ discard block |
||
| 226 | 226 | return $this->getInfoKey('scheme'); |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - /** |
|
| 230 | - * Retrieves the port specified in the URL, or -1 if none is preseent. |
|
| 231 | - * @return int |
|
| 232 | - */ |
|
| 229 | + /** |
|
| 230 | + * Retrieves the port specified in the URL, or -1 if none is preseent. |
|
| 231 | + * @return int |
|
| 232 | + */ |
|
| 233 | 233 | public function getPort() : int |
| 234 | 234 | { |
| 235 | 235 | $port = $this->getInfoKey('port'); |
@@ -241,13 +241,13 @@ discard block |
||
| 241 | 241 | return -1; |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | - /** |
|
| 245 | - * Retrieves the raw query string, or an empty string if none is present. |
|
| 246 | - * |
|
| 247 | - * @return string |
|
| 248 | - * |
|
| 249 | - * @see URLInfo::getParams() |
|
| 250 | - */ |
|
| 244 | + /** |
|
| 245 | + * Retrieves the raw query string, or an empty string if none is present. |
|
| 246 | + * |
|
| 247 | + * @return string |
|
| 248 | + * |
|
| 249 | + * @see URLInfo::getParams() |
|
| 250 | + */ |
|
| 251 | 251 | public function getQuery() : string |
| 252 | 252 | { |
| 253 | 253 | return $this->getInfoKey('query'); |
@@ -263,20 +263,20 @@ discard block |
||
| 263 | 263 | return $this->getInfoKey('pass'); |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | - /** |
|
| 267 | - * Whether the URL contains a port number. |
|
| 268 | - * @return bool |
|
| 269 | - */ |
|
| 266 | + /** |
|
| 267 | + * Whether the URL contains a port number. |
|
| 268 | + * @return bool |
|
| 269 | + */ |
|
| 270 | 270 | public function hasPort() : bool |
| 271 | 271 | { |
| 272 | 272 | return $this->getPort() !== -1; |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | - /** |
|
| 276 | - * Alias for the hasParams() method. |
|
| 277 | - * @return bool |
|
| 278 | - * @see URLInfo::hasParams() |
|
| 279 | - */ |
|
| 275 | + /** |
|
| 276 | + * Alias for the hasParams() method. |
|
| 277 | + * @return bool |
|
| 278 | + * @see URLInfo::hasParams() |
|
| 279 | + */ |
|
| 280 | 280 | public function hasQuery() : bool |
| 281 | 281 | { |
| 282 | 282 | return $this->hasParams(); |
@@ -321,23 +321,23 @@ discard block |
||
| 321 | 321 | return ''; |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | - /** |
|
| 325 | - * Retrieves a normalized URL: this ensures that all parameters |
|
| 326 | - * in the URL are always in the same order. |
|
| 327 | - * |
|
| 328 | - * @return string |
|
| 329 | - */ |
|
| 324 | + /** |
|
| 325 | + * Retrieves a normalized URL: this ensures that all parameters |
|
| 326 | + * in the URL are always in the same order. |
|
| 327 | + * |
|
| 328 | + * @return string |
|
| 329 | + */ |
|
| 330 | 330 | public function getNormalized() : string |
| 331 | 331 | { |
| 332 | 332 | return $this->normalize(true); |
| 333 | 333 | } |
| 334 | 334 | |
| 335 | - /** |
|
| 336 | - * Like getNormalized(), but if a username and password are present |
|
| 337 | - * in the URL, returns the URL without them. |
|
| 338 | - * |
|
| 339 | - * @return string |
|
| 340 | - */ |
|
| 335 | + /** |
|
| 336 | + * Like getNormalized(), but if a username and password are present |
|
| 337 | + * in the URL, returns the URL without them. |
|
| 338 | + * |
|
| 339 | + * @return string |
|
| 340 | + */ |
|
| 341 | 341 | public function getNormalizedWithoutAuth() : string |
| 342 | 342 | { |
| 343 | 343 | return $this->normalize(false); |
@@ -358,25 +358,25 @@ discard block |
||
| 358 | 358 | return $this->normalizer->normalize(); |
| 359 | 359 | } |
| 360 | 360 | |
| 361 | - /** |
|
| 362 | - * Creates a hash of the URL, which can be used for comparisons. |
|
| 363 | - * Since any parameters in the URL's query are sorted alphabetically, |
|
| 364 | - * the same links with a different parameter order will have the |
|
| 365 | - * same hash. |
|
| 366 | - * |
|
| 367 | - * @return string |
|
| 368 | - */ |
|
| 361 | + /** |
|
| 362 | + * Creates a hash of the URL, which can be used for comparisons. |
|
| 363 | + * Since any parameters in the URL's query are sorted alphabetically, |
|
| 364 | + * the same links with a different parameter order will have the |
|
| 365 | + * same hash. |
|
| 366 | + * |
|
| 367 | + * @return string |
|
| 368 | + */ |
|
| 369 | 369 | public function getHash() |
| 370 | 370 | { |
| 371 | 371 | return \AppUtils\ConvertHelper::string2shortHash($this->getNormalized()); |
| 372 | 372 | } |
| 373 | 373 | |
| 374 | - /** |
|
| 375 | - * Highlights the URL using HTML tags with specific highlighting |
|
| 376 | - * class names. |
|
| 377 | - * |
|
| 378 | - * @return string Will return an empty string if the URL is not valid. |
|
| 379 | - */ |
|
| 374 | + /** |
|
| 375 | + * Highlights the URL using HTML tags with specific highlighting |
|
| 376 | + * class names. |
|
| 377 | + * |
|
| 378 | + * @return string Will return an empty string if the URL is not valid. |
|
| 379 | + */ |
|
| 380 | 380 | public function getHighlighted() : string |
| 381 | 381 | { |
| 382 | 382 | if(!$this->isValid()) { |
@@ -410,15 +410,15 @@ discard block |
||
| 410 | 410 | return count($params); |
| 411 | 411 | } |
| 412 | 412 | |
| 413 | - /** |
|
| 414 | - * Retrieves all parameters specified in the url, |
|
| 415 | - * if any, as an associative array. |
|
| 416 | - * |
|
| 417 | - * NOTE: Ignores parameters that have been added |
|
| 418 | - * to the excluded parameters list. |
|
| 419 | - * |
|
| 420 | - * @return array |
|
| 421 | - */ |
|
| 413 | + /** |
|
| 414 | + * Retrieves all parameters specified in the url, |
|
| 415 | + * if any, as an associative array. |
|
| 416 | + * |
|
| 417 | + * NOTE: Ignores parameters that have been added |
|
| 418 | + * to the excluded parameters list. |
|
| 419 | + * |
|
| 420 | + * @return array |
|
| 421 | + */ |
|
| 422 | 422 | public function getParams() : array |
| 423 | 423 | { |
| 424 | 424 | if(!$this->paramExclusion || empty($this->excludedParams)) { |
@@ -436,22 +436,22 @@ discard block |
||
| 436 | 436 | return $keep; |
| 437 | 437 | } |
| 438 | 438 | |
| 439 | - /** |
|
| 440 | - * Retrieves the names of all parameters present in the URL, if any. |
|
| 441 | - * @return string[] |
|
| 442 | - */ |
|
| 439 | + /** |
|
| 440 | + * Retrieves the names of all parameters present in the URL, if any. |
|
| 441 | + * @return string[] |
|
| 442 | + */ |
|
| 443 | 443 | public function getParamNames() : array |
| 444 | 444 | { |
| 445 | 445 | $params = $this->getParams(); |
| 446 | 446 | return array_keys($params); |
| 447 | 447 | } |
| 448 | 448 | |
| 449 | - /** |
|
| 450 | - * Retrieves a specific parameter value from the URL. |
|
| 451 | - * |
|
| 452 | - * @param string $name |
|
| 453 | - * @return string The parameter value, or an empty string if it does not exist. |
|
| 454 | - */ |
|
| 449 | + /** |
|
| 450 | + * Retrieves a specific parameter value from the URL. |
|
| 451 | + * |
|
| 452 | + * @param string $name |
|
| 453 | + * @return string The parameter value, or an empty string if it does not exist. |
|
| 454 | + */ |
|
| 455 | 455 | public function getParam(string $name) : string |
| 456 | 456 | { |
| 457 | 457 | if(isset($this->info['params'][$name])) { |
@@ -461,16 +461,16 @@ discard block |
||
| 461 | 461 | return ''; |
| 462 | 462 | } |
| 463 | 463 | |
| 464 | - /** |
|
| 465 | - * Excludes an URL parameter entirely if present: |
|
| 466 | - * the parser will act as if the parameter was not |
|
| 467 | - * even present in the source URL, effectively |
|
| 468 | - * stripping it. |
|
| 469 | - * |
|
| 470 | - * @param string $name |
|
| 471 | - * @param string $reason A human readable explanation why this is excluded - used when highlighting links. |
|
| 472 | - * @return URLInfo |
|
| 473 | - */ |
|
| 464 | + /** |
|
| 465 | + * Excludes an URL parameter entirely if present: |
|
| 466 | + * the parser will act as if the parameter was not |
|
| 467 | + * even present in the source URL, effectively |
|
| 468 | + * stripping it. |
|
| 469 | + * |
|
| 470 | + * @param string $name |
|
| 471 | + * @param string $reason A human readable explanation why this is excluded - used when highlighting links. |
|
| 472 | + * @return URLInfo |
|
| 473 | + */ |
|
| 474 | 474 | public function excludeParam(string $name, string $reason) : URLInfo |
| 475 | 475 | { |
| 476 | 476 | if(!isset($this->excludedParams[$name])) |
@@ -523,25 +523,25 @@ discard block |
||
| 523 | 523 | return self::$typeLabels[$this->getType()]; |
| 524 | 524 | } |
| 525 | 525 | |
| 526 | - /** |
|
| 527 | - * Whether excluded parameters should be highlighted in |
|
| 528 | - * a different color in the URL when using the |
|
| 529 | - * {@link URLInfo::getHighlighted()} method. |
|
| 530 | - * |
|
| 531 | - * @param bool $highlight |
|
| 532 | - * @return URLInfo |
|
| 533 | - */ |
|
| 526 | + /** |
|
| 527 | + * Whether excluded parameters should be highlighted in |
|
| 528 | + * a different color in the URL when using the |
|
| 529 | + * {@link URLInfo::getHighlighted()} method. |
|
| 530 | + * |
|
| 531 | + * @param bool $highlight |
|
| 532 | + * @return URLInfo |
|
| 533 | + */ |
|
| 534 | 534 | public function setHighlightExcluded(bool $highlight=true) : URLInfo |
| 535 | 535 | { |
| 536 | 536 | $this->highlightExcluded = $highlight; |
| 537 | 537 | return $this; |
| 538 | 538 | } |
| 539 | 539 | |
| 540 | - /** |
|
| 541 | - * Returns an array with all relevant URL information. |
|
| 542 | - * |
|
| 543 | - * @return array |
|
| 544 | - */ |
|
| 540 | + /** |
|
| 541 | + * Returns an array with all relevant URL information. |
|
| 542 | + * |
|
| 543 | + * @return array |
|
| 544 | + */ |
|
| 545 | 545 | public function toArray() : array |
| 546 | 546 | { |
| 547 | 547 | return array( |
@@ -585,24 +585,24 @@ discard block |
||
| 585 | 585 | return $this; |
| 586 | 586 | } |
| 587 | 587 | |
| 588 | - /** |
|
| 589 | - * Whether the parameter exclusion mode is enabled: |
|
| 590 | - * In this case, if any parameters have been added to the |
|
| 591 | - * exclusion list, all relevant methods will exclude these. |
|
| 592 | - * |
|
| 593 | - * @return bool |
|
| 594 | - */ |
|
| 588 | + /** |
|
| 589 | + * Whether the parameter exclusion mode is enabled: |
|
| 590 | + * In this case, if any parameters have been added to the |
|
| 591 | + * exclusion list, all relevant methods will exclude these. |
|
| 592 | + * |
|
| 593 | + * @return bool |
|
| 594 | + */ |
|
| 595 | 595 | public function isParamExclusionEnabled() : bool |
| 596 | 596 | { |
| 597 | 597 | return $this->paramExclusion; |
| 598 | 598 | } |
| 599 | 599 | |
| 600 | - /** |
|
| 601 | - * Checks whether the link contains any parameters that |
|
| 602 | - * are on the list of excluded parameters. |
|
| 603 | - * |
|
| 604 | - * @return bool |
|
| 605 | - */ |
|
| 600 | + /** |
|
| 601 | + * Checks whether the link contains any parameters that |
|
| 602 | + * are on the list of excluded parameters. |
|
| 603 | + * |
|
| 604 | + * @return bool |
|
| 605 | + */ |
|
| 606 | 606 | public function containsExcludedParams() : bool |
| 607 | 607 | { |
| 608 | 608 | if(empty($this->excludedParams)) { |
@@ -670,16 +670,16 @@ discard block |
||
| 670 | 670 | return $this->highlightExcluded; |
| 671 | 671 | } |
| 672 | 672 | |
| 673 | - /** |
|
| 674 | - * Checks if the URL exists, i.e. can be connected to. Will return |
|
| 675 | - * true if the returned HTTP status code is `200` or `302`. |
|
| 676 | - * |
|
| 677 | - * NOTE: If the target URL requires HTTP authentication, the username |
|
| 678 | - * and password should be integrated into the URL. |
|
| 679 | - * |
|
| 680 | - * @return bool |
|
| 681 | - * @throws BaseException |
|
| 682 | - */ |
|
| 673 | + /** |
|
| 674 | + * Checks if the URL exists, i.e. can be connected to. Will return |
|
| 675 | + * true if the returned HTTP status code is `200` or `302`. |
|
| 676 | + * |
|
| 677 | + * NOTE: If the target URL requires HTTP authentication, the username |
|
| 678 | + * and password should be integrated into the URL. |
|
| 679 | + * |
|
| 680 | + * @return bool |
|
| 681 | + * @throws BaseException |
|
| 682 | + */ |
|
| 683 | 683 | public function tryConnect(bool $verifySSL=true) : bool |
| 684 | 684 | { |
| 685 | 685 | requireCURL(); |
@@ -128,9 +128,9 @@ discard block |
||
| 128 | 128 | * @param bool $enabled |
| 129 | 129 | * @return URLInfo |
| 130 | 130 | */ |
| 131 | - public function setUTFEncoding(bool $enabled=true) : URLInfo |
|
| 131 | + public function setUTFEncoding(bool $enabled = true) : URLInfo |
|
| 132 | 132 | { |
| 133 | - if($this->encodeUTFChars !== $enabled) |
|
| 133 | + if ($this->encodeUTFChars !== $enabled) |
|
| 134 | 134 | { |
| 135 | 135 | $this->encodeUTFChars = $enabled; |
| 136 | 136 | $this->parse(); // re-parse the URL to apply the changes |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | { |
| 235 | 235 | $port = $this->getInfoKey('port'); |
| 236 | 236 | |
| 237 | - if(!empty($port)) { |
|
| 237 | + if (!empty($port)) { |
|
| 238 | 238 | return (int)$port; |
| 239 | 239 | } |
| 240 | 240 | |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | |
| 315 | 315 | protected function getInfoKey(string $name) : string |
| 316 | 316 | { |
| 317 | - if(isset($this->info[$name])) { |
|
| 317 | + if (isset($this->info[$name])) { |
|
| 318 | 318 | return (string)$this->info[$name]; |
| 319 | 319 | } |
| 320 | 320 | |
@@ -343,13 +343,13 @@ discard block |
||
| 343 | 343 | return $this->normalize(false); |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | - protected function normalize(bool $auth=true) : string |
|
| 346 | + protected function normalize(bool $auth = true) : string |
|
| 347 | 347 | { |
| 348 | - if(!$this->isValid()) { |
|
| 348 | + if (!$this->isValid()) { |
|
| 349 | 349 | return ''; |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | - if(!isset($this->normalizer)) { |
|
| 352 | + if (!isset($this->normalizer)) { |
|
| 353 | 353 | $this->normalizer = new URLInfo_Normalizer($this); |
| 354 | 354 | } |
| 355 | 355 | |
@@ -379,7 +379,7 @@ discard block |
||
| 379 | 379 | */ |
| 380 | 380 | public function getHighlighted() : string |
| 381 | 381 | { |
| 382 | - if(!$this->isValid()) { |
|
| 382 | + if (!$this->isValid()) { |
|
| 383 | 383 | return ''; |
| 384 | 384 | } |
| 385 | 385 | |
@@ -421,14 +421,14 @@ discard block |
||
| 421 | 421 | */ |
| 422 | 422 | public function getParams() : array |
| 423 | 423 | { |
| 424 | - if(!$this->paramExclusion || empty($this->excludedParams)) { |
|
| 424 | + if (!$this->paramExclusion || empty($this->excludedParams)) { |
|
| 425 | 425 | return $this->info['params']; |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | 428 | $keep = array(); |
| 429 | - foreach($this->info['params'] as $name => $value) |
|
| 429 | + foreach ($this->info['params'] as $name => $value) |
|
| 430 | 430 | { |
| 431 | - if(!isset($this->excludedParams[$name])) { |
|
| 431 | + if (!isset($this->excludedParams[$name])) { |
|
| 432 | 432 | $keep[$name] = $value; |
| 433 | 433 | } |
| 434 | 434 | } |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | */ |
| 455 | 455 | public function getParam(string $name) : string |
| 456 | 456 | { |
| 457 | - if(isset($this->info['params'][$name])) { |
|
| 457 | + if (isset($this->info['params'][$name])) { |
|
| 458 | 458 | return $this->info['params'][$name]; |
| 459 | 459 | } |
| 460 | 460 | |
@@ -473,7 +473,7 @@ discard block |
||
| 473 | 473 | */ |
| 474 | 474 | public function excludeParam(string $name, string $reason) : URLInfo |
| 475 | 475 | { |
| 476 | - if(!isset($this->excludedParams[$name])) |
|
| 476 | + if (!isset($this->excludedParams[$name])) |
|
| 477 | 477 | { |
| 478 | 478 | $this->excludedParams[$name] = $reason; |
| 479 | 479 | $this->setParamExclusion(); |
@@ -499,7 +499,7 @@ discard block |
||
| 499 | 499 | |
| 500 | 500 | public function getTypeLabel() : string |
| 501 | 501 | { |
| 502 | - if(!isset(self::$typeLabels)) |
|
| 502 | + if (!isset(self::$typeLabels)) |
|
| 503 | 503 | { |
| 504 | 504 | self::$typeLabels = array( |
| 505 | 505 | self::TYPE_EMAIL => t('Email'), |
@@ -511,7 +511,7 @@ discard block |
||
| 511 | 511 | |
| 512 | 512 | $type = $this->getType(); |
| 513 | 513 | |
| 514 | - if(!isset(self::$typeLabels[$type])) |
|
| 514 | + if (!isset(self::$typeLabels[$type])) |
|
| 515 | 515 | { |
| 516 | 516 | throw new BaseException( |
| 517 | 517 | sprintf('Unknown URL type label for type [%s].', $type), |
@@ -531,7 +531,7 @@ discard block |
||
| 531 | 531 | * @param bool $highlight |
| 532 | 532 | * @return URLInfo |
| 533 | 533 | */ |
| 534 | - public function setHighlightExcluded(bool $highlight=true) : URLInfo |
|
| 534 | + public function setHighlightExcluded(bool $highlight = true) : URLInfo |
|
| 535 | 535 | { |
| 536 | 536 | $this->highlightExcluded = $highlight; |
| 537 | 537 | return $this; |
@@ -579,7 +579,7 @@ discard block |
||
| 579 | 579 | * @see URLInfo::isParamExclusionEnabled() |
| 580 | 580 | * @see URLInfo::setHighlightExcluded() |
| 581 | 581 | */ |
| 582 | - public function setParamExclusion(bool $enabled=true) : URLInfo |
|
| 582 | + public function setParamExclusion(bool $enabled = true) : URLInfo |
|
| 583 | 583 | { |
| 584 | 584 | $this->paramExclusion = $enabled; |
| 585 | 585 | return $this; |
@@ -605,13 +605,13 @@ discard block |
||
| 605 | 605 | */ |
| 606 | 606 | public function containsExcludedParams() : bool |
| 607 | 607 | { |
| 608 | - if(empty($this->excludedParams)) { |
|
| 608 | + if (empty($this->excludedParams)) { |
|
| 609 | 609 | return false; |
| 610 | 610 | } |
| 611 | 611 | |
| 612 | 612 | $names = array_keys($this->info['params']); |
| 613 | - foreach($names as $name) { |
|
| 614 | - if(isset($this->excludedParams[$name])) { |
|
| 613 | + foreach ($names as $name) { |
|
| 614 | + if (isset($this->excludedParams[$name])) { |
|
| 615 | 615 | return true; |
| 616 | 616 | } |
| 617 | 617 | } |
@@ -627,7 +627,7 @@ discard block |
||
| 627 | 627 | |
| 628 | 628 | public function offsetSet($offset, $value) |
| 629 | 629 | { |
| 630 | - if(in_array($offset, $this->infoKeys)) { |
|
| 630 | + if (in_array($offset, $this->infoKeys)) { |
|
| 631 | 631 | $this->info[$offset] = $value; |
| 632 | 632 | } |
| 633 | 633 | } |
@@ -644,11 +644,11 @@ discard block |
||
| 644 | 644 | |
| 645 | 645 | public function offsetGet($offset) |
| 646 | 646 | { |
| 647 | - if($offset === 'port') { |
|
| 647 | + if ($offset === 'port') { |
|
| 648 | 648 | return $this->getPort(); |
| 649 | 649 | } |
| 650 | 650 | |
| 651 | - if(in_array($offset, $this->infoKeys)) { |
|
| 651 | + if (in_array($offset, $this->infoKeys)) { |
|
| 652 | 652 | return $this->getInfoKey($offset); |
| 653 | 653 | } |
| 654 | 654 | |
@@ -680,12 +680,12 @@ discard block |
||
| 680 | 680 | * @return bool |
| 681 | 681 | * @throws BaseException |
| 682 | 682 | */ |
| 683 | - public function tryConnect(bool $verifySSL=true) : bool |
|
| 683 | + public function tryConnect(bool $verifySSL = true) : bool |
|
| 684 | 684 | { |
| 685 | 685 | requireCURL(); |
| 686 | 686 | |
| 687 | 687 | $ch = curl_init(); |
| 688 | - if(!is_resource($ch)) |
|
| 688 | + if (!is_resource($ch)) |
|
| 689 | 689 | { |
| 690 | 690 | throw new BaseException( |
| 691 | 691 | 'Could not initialize a new cURL instance.', |
@@ -701,13 +701,13 @@ discard block |
||
| 701 | 701 | curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
| 702 | 702 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
| 703 | 703 | |
| 704 | - if(!$verifySSL) |
|
| 704 | + if (!$verifySSL) |
|
| 705 | 705 | { |
| 706 | 706 | curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); |
| 707 | 707 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
| 708 | 708 | } |
| 709 | 709 | |
| 710 | - if($this->hasUsername()) |
|
| 710 | + if ($this->hasUsername()) |
|
| 711 | 711 | { |
| 712 | 712 | curl_setopt($ch, CURLOPT_USERNAME, $this->getUsername()); |
| 713 | 713 | curl_setopt($ch, CURLOPT_PASSWORD, $this->getPassword()); |
@@ -23,24 +23,24 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | class URLInfo_Parser |
| 25 | 25 | { |
| 26 | - /** |
|
| 27 | - * @var string |
|
| 28 | - */ |
|
| 26 | + /** |
|
| 27 | + * @var string |
|
| 28 | + */ |
|
| 29 | 29 | protected $url; |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * @var bool |
|
| 33 | - */ |
|
| 31 | + /** |
|
| 32 | + * @var bool |
|
| 33 | + */ |
|
| 34 | 34 | protected $isValid = false; |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @var array |
|
| 38 | - */ |
|
| 36 | + /** |
|
| 37 | + * @var array |
|
| 38 | + */ |
|
| 39 | 39 | protected $info; |
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * @var array|NULL |
|
| 43 | - */ |
|
| 41 | + /** |
|
| 42 | + * @var array|NULL |
|
| 43 | + */ |
|
| 44 | 44 | protected $error; |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -56,25 +56,25 @@ discard block |
||
| 56 | 56 | 'file' |
| 57 | 57 | ); |
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * Stores a list of all unicode characters in the URL |
|
| 61 | - * that have been filtered out before parsing it with |
|
| 62 | - * parse_url. |
|
| 63 | - * |
|
| 64 | - * @var string[]string |
|
| 65 | - */ |
|
| 59 | + /** |
|
| 60 | + * Stores a list of all unicode characters in the URL |
|
| 61 | + * that have been filtered out before parsing it with |
|
| 62 | + * parse_url. |
|
| 63 | + * |
|
| 64 | + * @var string[]string |
|
| 65 | + */ |
|
| 66 | 66 | protected $unicodeChars = array(); |
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * @var bool |
|
| 70 | - */ |
|
| 68 | + /** |
|
| 69 | + * @var bool |
|
| 70 | + */ |
|
| 71 | 71 | protected $encodeUTF = false; |
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * |
|
| 75 | - * @param string $url The target URL. |
|
| 76 | - * @param bool $encodeUTF Whether to URL encode any plain text unicode characters. |
|
| 77 | - */ |
|
| 73 | + /** |
|
| 74 | + * |
|
| 75 | + * @param string $url The target URL. |
|
| 76 | + * @param bool $encodeUTF Whether to URL encode any plain text unicode characters. |
|
| 77 | + */ |
|
| 78 | 78 | public function __construct(string $url, bool $encodeUTF) |
| 79 | 79 | { |
| 80 | 80 | $this->url = $url; |
@@ -87,12 +87,12 @@ discard block |
||
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - /** |
|
| 91 | - * Retrieves the array as parsed by PHP's parse_url, |
|
| 92 | - * filtered and adjusted as necessary. |
|
| 93 | - * |
|
| 94 | - * @return array |
|
| 95 | - */ |
|
| 90 | + /** |
|
| 91 | + * Retrieves the array as parsed by PHP's parse_url, |
|
| 92 | + * filtered and adjusted as necessary. |
|
| 93 | + * |
|
| 94 | + * @return array |
|
| 95 | + */ |
|
| 96 | 96 | public function getInfo() : array |
| 97 | 97 | { |
| 98 | 98 | return $this->info; |
@@ -114,11 +114,11 @@ discard block |
||
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - /** |
|
| 118 | - * Finds any non-url encoded unicode characters in |
|
| 119 | - * the URL, and encodes them before the URL is |
|
| 120 | - * passed to parse_url. |
|
| 121 | - */ |
|
| 117 | + /** |
|
| 118 | + * Finds any non-url encoded unicode characters in |
|
| 119 | + * the URL, and encodes them before the URL is |
|
| 120 | + * passed to parse_url. |
|
| 121 | + */ |
|
| 122 | 122 | protected function filterUnicodeChars() : void |
| 123 | 123 | { |
| 124 | 124 | $chars = \AppUtils\ConvertHelper::string2array($this->url); |
@@ -236,11 +236,11 @@ discard block |
||
| 236 | 236 | return false; |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - /** |
|
| 240 | - * Goes through all information in the parse_url result |
|
| 241 | - * array, and attempts to fix any user errors in formatting |
|
| 242 | - * that can be recovered from, mostly regarding stray spaces. |
|
| 243 | - */ |
|
| 239 | + /** |
|
| 240 | + * Goes through all information in the parse_url result |
|
| 241 | + * array, and attempts to fix any user errors in formatting |
|
| 242 | + * that can be recovered from, mostly regarding stray spaces. |
|
| 243 | + */ |
|
| 244 | 244 | protected function filterParsed() |
| 245 | 245 | { |
| 246 | 246 | $this->info['params'] = array(); |
@@ -269,13 +269,13 @@ discard block |
||
| 269 | 269 | } |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | - /** |
|
| 273 | - * Recursively goes through the array, and converts all previously |
|
| 274 | - * URL encoded characters with their unicode character counterparts. |
|
| 275 | - * |
|
| 276 | - * @param array $subject |
|
| 277 | - * @return array |
|
| 278 | - */ |
|
| 272 | + /** |
|
| 273 | + * Recursively goes through the array, and converts all previously |
|
| 274 | + * URL encoded characters with their unicode character counterparts. |
|
| 275 | + * |
|
| 276 | + * @param array $subject |
|
| 277 | + * @return array |
|
| 278 | + */ |
|
| 279 | 279 | protected function restoreUnicodeChars(array $subject) : array |
| 280 | 280 | { |
| 281 | 281 | $result = array(); |
@@ -299,13 +299,13 @@ discard block |
||
| 299 | 299 | return $result; |
| 300 | 300 | } |
| 301 | 301 | |
| 302 | - /** |
|
| 303 | - * Replaces all URL encoded unicode characters |
|
| 304 | - * in the string with the unicode character. |
|
| 305 | - * |
|
| 306 | - * @param string $string |
|
| 307 | - * @return string |
|
| 308 | - */ |
|
| 302 | + /** |
|
| 303 | + * Replaces all URL encoded unicode characters |
|
| 304 | + * in the string with the unicode character. |
|
| 305 | + * |
|
| 306 | + * @param string $string |
|
| 307 | + * @return string |
|
| 308 | + */ |
|
| 309 | 309 | protected function restoreUnicodeChar(string $string) : string |
| 310 | 310 | { |
| 311 | 311 | if(strstr($string, '%')) |
@@ -363,21 +363,21 @@ discard block |
||
| 363 | 363 | ); |
| 364 | 364 | } |
| 365 | 365 | |
| 366 | - /** |
|
| 367 | - * Checks whether the URL that was parsed is valid. |
|
| 368 | - * @return bool |
|
| 369 | - */ |
|
| 366 | + /** |
|
| 367 | + * Checks whether the URL that was parsed is valid. |
|
| 368 | + * @return bool |
|
| 369 | + */ |
|
| 370 | 370 | public function isValid() : bool |
| 371 | 371 | { |
| 372 | 372 | return $this->isValid; |
| 373 | 373 | } |
| 374 | 374 | |
| 375 | - /** |
|
| 376 | - * If the validation failed, retrieves the validation |
|
| 377 | - * error message. |
|
| 378 | - * |
|
| 379 | - * @return string |
|
| 380 | - */ |
|
| 375 | + /** |
|
| 376 | + * If the validation failed, retrieves the validation |
|
| 377 | + * error message. |
|
| 378 | + * |
|
| 379 | + * @return string |
|
| 380 | + */ |
|
| 381 | 381 | public function getErrorMessage() : string |
| 382 | 382 | { |
| 383 | 383 | if(isset($this->error)) { |
@@ -387,12 +387,12 @@ discard block |
||
| 387 | 387 | return ''; |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | - /** |
|
| 391 | - * If the validation failed, retrieves the validation |
|
| 392 | - * error code. |
|
| 393 | - * |
|
| 394 | - * @return int |
|
| 395 | - */ |
|
| 390 | + /** |
|
| 391 | + * If the validation failed, retrieves the validation |
|
| 392 | + * error code. |
|
| 393 | + * |
|
| 394 | + * @return int |
|
| 395 | + */ |
|
| 396 | 396 | public function getErrorCode() : int |
| 397 | 397 | { |
| 398 | 398 | if(isset($this->error)) { |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | $this->parse(); |
| 84 | 84 | |
| 85 | - if(!$this->detectType()) { |
|
| 85 | + if (!$this->detectType()) { |
|
| 86 | 86 | $this->validate(); |
| 87 | 87 | } |
| 88 | 88 | } |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | // if the URL contains any URL characters, and we |
| 110 | 110 | // do not want them URL encoded, restore them. |
| 111 | - if(!$this->encodeUTF && !empty($this->unicodeChars)) |
|
| 111 | + if (!$this->encodeUTF && !empty($this->unicodeChars)) |
|
| 112 | 112 | { |
| 113 | 113 | $this->info = $this->restoreUnicodeChars($this->info); |
| 114 | 114 | } |
@@ -125,13 +125,13 @@ discard block |
||
| 125 | 125 | |
| 126 | 126 | $keep = array(); |
| 127 | 127 | |
| 128 | - foreach($chars as $char) |
|
| 128 | + foreach ($chars as $char) |
|
| 129 | 129 | { |
| 130 | - if(preg_match('/\p{L}/usix', $char)) |
|
| 130 | + if (preg_match('/\p{L}/usix', $char)) |
|
| 131 | 131 | { |
| 132 | 132 | $encoded = rawurlencode($char); |
| 133 | 133 | |
| 134 | - if($encoded != $char) |
|
| 134 | + if ($encoded != $char) |
|
| 135 | 135 | { |
| 136 | 136 | $this->unicodeChars[$encoded] = $char; |
| 137 | 137 | $char = $encoded; |
@@ -152,11 +152,11 @@ discard block |
||
| 152 | 152 | 'phoneLink' |
| 153 | 153 | ); |
| 154 | 154 | |
| 155 | - foreach($types as $type) |
|
| 155 | + foreach ($types as $type) |
|
| 156 | 156 | { |
| 157 | 157 | $method = 'detectType_'.$type; |
| 158 | 158 | |
| 159 | - if($this->$method() === true) |
|
| 159 | + if ($this->$method() === true) |
|
| 160 | 160 | { |
| 161 | 161 | $this->isValid = true; |
| 162 | 162 | return true; |
@@ -174,11 +174,11 @@ discard block |
||
| 174 | 174 | 'hostIsPresent' |
| 175 | 175 | ); |
| 176 | 176 | |
| 177 | - foreach($validations as $validation) |
|
| 177 | + foreach ($validations as $validation) |
|
| 178 | 178 | { |
| 179 | 179 | $method = 'validate_'.$validation; |
| 180 | 180 | |
| 181 | - if($this->$method() !== true) { |
|
| 181 | + if ($this->$method() !== true) { |
|
| 182 | 182 | return; |
| 183 | 183 | } |
| 184 | 184 | } |
@@ -191,13 +191,13 @@ discard block |
||
| 191 | 191 | // every link needs a host. This case can happen for ex, if |
| 192 | 192 | // the link starts with a typo with only one slash, like: |
| 193 | 193 | // "http:/hostname" |
| 194 | - if(isset($this->info['host'])) { |
|
| 194 | + if (isset($this->info['host'])) { |
|
| 195 | 195 | return true; |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | $this->setError( |
| 199 | 199 | URLInfo::ERROR_MISSING_HOST, |
| 200 | - t('Cannot determine the link\'s host name.') . ' ' . |
|
| 200 | + t('Cannot determine the link\'s host name.').' '. |
|
| 201 | 201 | t('This usually happens when there\'s a typo somewhere.') |
| 202 | 202 | ); |
| 203 | 203 | |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | |
| 207 | 207 | protected function validate_schemeIsSet() : bool |
| 208 | 208 | { |
| 209 | - if(isset($this->info['scheme'])) { |
|
| 209 | + if (isset($this->info['scheme'])) { |
|
| 210 | 210 | return true; |
| 211 | 211 | } |
| 212 | 212 | |
@@ -223,13 +223,13 @@ discard block |
||
| 223 | 223 | |
| 224 | 224 | protected function validate_schemeIsKnown() : bool |
| 225 | 225 | { |
| 226 | - if(in_array($this->info['scheme'], $this->knownSchemes)) { |
|
| 226 | + if (in_array($this->info['scheme'], $this->knownSchemes)) { |
|
| 227 | 227 | return true; |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | $this->setError( |
| 231 | 231 | URLInfo::ERROR_INVALID_SCHEME, |
| 232 | - t('The scheme %1$s is not supported for links.', $this->info['scheme']) . ' ' . |
|
| 232 | + t('The scheme %1$s is not supported for links.', $this->info['scheme']).' '. |
|
| 233 | 233 | t('Valid schemes are: %1$s.', implode(', ', $this->knownSchemes)) |
| 234 | 234 | ); |
| 235 | 235 | |
@@ -246,23 +246,23 @@ discard block |
||
| 246 | 246 | $this->info['params'] = array(); |
| 247 | 247 | $this->info['type'] = URLInfo::TYPE_URL; |
| 248 | 248 | |
| 249 | - if(isset($this->info['user'])) { |
|
| 249 | + if (isset($this->info['user'])) { |
|
| 250 | 250 | $this->info['user'] = urldecode($this->info['user']); |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | - if(isset($this->info['pass'])) { |
|
| 253 | + if (isset($this->info['pass'])) { |
|
| 254 | 254 | $this->info['pass'] = urldecode($this->info['pass']); |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | - if(isset($this->info['host'])) { |
|
| 257 | + if (isset($this->info['host'])) { |
|
| 258 | 258 | $this->info['host'] = str_replace(' ', '', $this->info['host']); |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | - if(isset($this->info['path'])) { |
|
| 261 | + if (isset($this->info['path'])) { |
|
| 262 | 262 | $this->info['path'] = str_replace(' ', '', $this->info['path']); |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | - if(isset($this->info['query']) && !empty($this->info['query'])) |
|
| 265 | + if (isset($this->info['query']) && !empty($this->info['query'])) |
|
| 266 | 266 | { |
| 267 | 267 | $this->info['params'] = \AppUtils\ConvertHelper::parseQueryString($this->info['query']); |
| 268 | 268 | ksort($this->info['params']); |
@@ -280,9 +280,9 @@ discard block |
||
| 280 | 280 | { |
| 281 | 281 | $result = array(); |
| 282 | 282 | |
| 283 | - foreach($subject as $key => $val) |
|
| 283 | + foreach ($subject as $key => $val) |
|
| 284 | 284 | { |
| 285 | - if(is_array($val)) |
|
| 285 | + if (is_array($val)) |
|
| 286 | 286 | { |
| 287 | 287 | $val = $this->restoreUnicodeChars($val); |
| 288 | 288 | } |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | */ |
| 309 | 309 | protected function restoreUnicodeChar(string $string) : string |
| 310 | 310 | { |
| 311 | - if(strstr($string, '%')) |
|
| 311 | + if (strstr($string, '%')) |
|
| 312 | 312 | { |
| 313 | 313 | return str_replace(array_keys($this->unicodeChars), array_values($this->unicodeChars), $string); |
| 314 | 314 | } |
@@ -318,12 +318,12 @@ discard block |
||
| 318 | 318 | |
| 319 | 319 | protected function detectType_email() : bool |
| 320 | 320 | { |
| 321 | - if(isset($this->info['scheme']) && $this->info['scheme'] == 'mailto') { |
|
| 321 | + if (isset($this->info['scheme']) && $this->info['scheme'] == 'mailto') { |
|
| 322 | 322 | $this->info['type'] = URLInfo::TYPE_EMAIL; |
| 323 | 323 | return true; |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | - if(isset($this->info['path']) && preg_match(\AppUtils\RegexHelper::REGEX_EMAIL, $this->info['path'])) |
|
| 326 | + if (isset($this->info['path']) && preg_match(\AppUtils\RegexHelper::REGEX_EMAIL, $this->info['path'])) |
|
| 327 | 327 | { |
| 328 | 328 | $this->info['scheme'] = 'mailto'; |
| 329 | 329 | $this->info['type'] = URLInfo::TYPE_EMAIL; |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | |
| 336 | 336 | protected function detectType_fragmentLink() : bool |
| 337 | 337 | { |
| 338 | - if(isset($this->info['fragment']) && !isset($this->info['scheme'])) { |
|
| 338 | + if (isset($this->info['fragment']) && !isset($this->info['scheme'])) { |
|
| 339 | 339 | $this->info['type'] = URLInfo::TYPE_FRAGMENT; |
| 340 | 340 | return true; |
| 341 | 341 | } |
@@ -345,7 +345,7 @@ discard block |
||
| 345 | 345 | |
| 346 | 346 | protected function detectType_phoneLink() : bool |
| 347 | 347 | { |
| 348 | - if(isset($this->info['scheme']) && $this->info['scheme'] == 'tel') { |
|
| 348 | + if (isset($this->info['scheme']) && $this->info['scheme'] == 'tel') { |
|
| 349 | 349 | $this->info['type'] = URLInfo::TYPE_PHONE; |
| 350 | 350 | return true; |
| 351 | 351 | } |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | */ |
| 381 | 381 | public function getErrorMessage() : string |
| 382 | 382 | { |
| 383 | - if(isset($this->error)) { |
|
| 383 | + if (isset($this->error)) { |
|
| 384 | 384 | return $this->error['message']; |
| 385 | 385 | } |
| 386 | 386 | |
@@ -395,7 +395,7 @@ discard block |
||
| 395 | 395 | */ |
| 396 | 396 | public function getErrorCode() : int |
| 397 | 397 | { |
| 398 | - if(isset($this->error)) { |
|
| 398 | + if (isset($this->error)) { |
|
| 399 | 399 | return $this->error['code']; |
| 400 | 400 | } |
| 401 | 401 | |
@@ -285,8 +285,7 @@ |
||
| 285 | 285 | if(is_array($val)) |
| 286 | 286 | { |
| 287 | 287 | $val = $this->restoreUnicodeChars($val); |
| 288 | - } |
|
| 289 | - else |
|
| 288 | + } else |
|
| 290 | 289 | { |
| 291 | 290 | $val = $this->restoreUnicodeChar($val); |
| 292 | 291 | } |
@@ -22,9 +22,9 @@ discard block |
||
| 22 | 22 | { |
| 23 | 23 | const ERROR_MALFORMATTED_STRING = 53801; |
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @var string[] |
|
| 27 | - */ |
|
| 25 | + /** |
|
| 26 | + * @var string[] |
|
| 27 | + */ |
|
| 28 | 28 | protected static $controlChars = array( |
| 29 | 29 | '0000-0008', // control chars |
| 30 | 30 | '000E-000F', // control chars |
@@ -32,19 +32,19 @@ discard block |
||
| 32 | 32 | '2000-200F', // non-breaking space and co |
| 33 | 33 | ); |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @var string|NULL |
|
| 37 | - */ |
|
| 35 | + /** |
|
| 36 | + * @var string|NULL |
|
| 37 | + */ |
|
| 38 | 38 | protected static $controlCharsRegex; |
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * @var string[] |
|
| 42 | - */ |
|
| 40 | + /** |
|
| 41 | + * @var string[] |
|
| 42 | + */ |
|
| 43 | 43 | protected static $hexAlphabet = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'); |
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * @var string[]|NULL |
|
| 47 | - */ |
|
| 45 | + /** |
|
| 46 | + * @var string[]|NULL |
|
| 47 | + */ |
|
| 48 | 48 | protected static $charsAsHex; |
| 49 | 49 | |
| 50 | 50 | public function __construct() |
@@ -67,13 +67,13 @@ discard block |
||
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * Retrieves the HEX character codes for all control |
|
| 72 | - * characters that the {@link stripControlCharacters()} |
|
| 73 | - * method will remove. |
|
| 74 | - * |
|
| 75 | - * @return string[] |
|
| 76 | - */ |
|
| 70 | + /** |
|
| 71 | + * Retrieves the HEX character codes for all control |
|
| 72 | + * characters that the {@link stripControlCharacters()} |
|
| 73 | + * method will remove. |
|
| 74 | + * |
|
| 75 | + * @return string[] |
|
| 76 | + */ |
|
| 77 | 77 | public function getCharsAsHex() : array |
| 78 | 78 | { |
| 79 | 79 | if (isset(self::$charsAsHex)) |
@@ -120,13 +120,13 @@ discard block |
||
| 120 | 120 | return $stack; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - /** |
|
| 124 | - * Retrieves an array of all control characters that |
|
| 125 | - * the {@link stripControlCharacters()} method will |
|
| 126 | - * remove, as the actual UTF-8 characters. |
|
| 127 | - * |
|
| 128 | - * @return string[] |
|
| 129 | - */ |
|
| 123 | + /** |
|
| 124 | + * Retrieves an array of all control characters that |
|
| 125 | + * the {@link stripControlCharacters()} method will |
|
| 126 | + * remove, as the actual UTF-8 characters. |
|
| 127 | + * |
|
| 128 | + * @return string[] |
|
| 129 | + */ |
|
| 130 | 130 | public function getCharsAsUTF8() : array |
| 131 | 131 | { |
| 132 | 132 | $chars = $this->getCharsAsHex(); |
@@ -139,12 +139,12 @@ discard block |
||
| 139 | 139 | return $result; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - /** |
|
| 143 | - * Retrieves all control characters as JSON encoded |
|
| 144 | - * characters, e.g. "\u200b". |
|
| 145 | - * |
|
| 146 | - * @return string[] |
|
| 147 | - */ |
|
| 142 | + /** |
|
| 143 | + * Retrieves all control characters as JSON encoded |
|
| 144 | + * characters, e.g. "\u200b". |
|
| 145 | + * |
|
| 146 | + * @return string[] |
|
| 147 | + */ |
|
| 148 | 148 | public function getCharsAsJSON() : array |
| 149 | 149 | { |
| 150 | 150 | $chars = $this->getCharsAsHex(); |
@@ -157,17 +157,17 @@ discard block |
||
| 157 | 157 | return $result; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - /** |
|
| 161 | - * Removes all control characters from the specified string |
|
| 162 | - * that can cause problems in some cases, like creating |
|
| 163 | - * valid XML documents. This includes invisible non-breaking |
|
| 164 | - * spaces. |
|
| 165 | - * |
|
| 166 | - * @param string $string |
|
| 167 | - * @return string |
|
| 168 | - * @see https://stackoverflow.com/a/8171868/2298192 |
|
| 169 | - * @see https://unicode-table.com/en |
|
| 170 | - */ |
|
| 160 | + /** |
|
| 161 | + * Removes all control characters from the specified string |
|
| 162 | + * that can cause problems in some cases, like creating |
|
| 163 | + * valid XML documents. This includes invisible non-breaking |
|
| 164 | + * spaces. |
|
| 165 | + * |
|
| 166 | + * @param string $string |
|
| 167 | + * @return string |
|
| 168 | + * @see https://stackoverflow.com/a/8171868/2298192 |
|
| 169 | + * @see https://unicode-table.com/en |
|
| 170 | + */ |
|
| 171 | 171 | public function stripControlCharacters(string $string) : string |
| 172 | 172 | { |
| 173 | 173 | if(empty($string)) |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | /** |
| 26 | 26 | * @var string[] |
| 27 | 27 | */ |
| 28 | - protected static $controlChars = array( |
|
| 28 | + protected static $controlChars = array( |
|
| 29 | 29 | '0000-0008', // control chars |
| 30 | 30 | '000E-000F', // control chars |
| 31 | 31 | '0010-001F', // control chars |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | public function __construct() |
| 51 | 51 | { |
| 52 | 52 | // create the regex from the unicode characters list |
| 53 | - if(!isset(self::$controlCharsRegex)) |
|
| 53 | + if (!isset(self::$controlCharsRegex)) |
|
| 54 | 54 | { |
| 55 | 55 | $chars = $this->getCharsAsHex(); |
| 56 | 56 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | // in the regular expression. |
| 59 | 59 | $stack = array(); |
| 60 | 60 | |
| 61 | - foreach($chars as $char) |
|
| 61 | + foreach ($chars as $char) |
|
| 62 | 62 | { |
| 63 | 63 | $stack[] = '\x{'.$char.'}'; |
| 64 | 64 | } |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | $stack = array(); |
| 85 | 85 | |
| 86 | - foreach(self::$controlChars as $char) |
|
| 86 | + foreach (self::$controlChars as $char) |
|
| 87 | 87 | { |
| 88 | 88 | $tokens = explode('-', $char); |
| 89 | 89 | $start = $tokens[0]; |
@@ -92,24 +92,24 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | $range = array(); |
| 94 | 94 | |
| 95 | - foreach(self::$hexAlphabet as $number) |
|
| 95 | + foreach (self::$hexAlphabet as $number) |
|
| 96 | 96 | { |
| 97 | 97 | $range[] = $prefix.$number; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | $use = false; |
| 101 | 101 | |
| 102 | - foreach($range as $number) |
|
| 102 | + foreach ($range as $number) |
|
| 103 | 103 | { |
| 104 | - if($number == $start) { |
|
| 104 | + if ($number == $start) { |
|
| 105 | 105 | $use = true; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - if($use) { |
|
| 108 | + if ($use) { |
|
| 109 | 109 | $stack[] = $number; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - if($number == $end) { |
|
| 112 | + if ($number == $end) { |
|
| 113 | 113 | break; |
| 114 | 114 | } |
| 115 | 115 | } |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | $chars = $this->getCharsAsHex(); |
| 133 | 133 | |
| 134 | 134 | $result = array(); |
| 135 | - foreach($chars as $char) { |
|
| 135 | + foreach ($chars as $char) { |
|
| 136 | 136 | $result[] = hex2bin($char); |
| 137 | 137 | } |
| 138 | 138 | |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | $chars = $this->getCharsAsHex(); |
| 151 | 151 | |
| 152 | 152 | $result = array(); |
| 153 | - foreach($chars as $char) { |
|
| 153 | + foreach ($chars as $char) { |
|
| 154 | 154 | $result[] = '\u'.strtolower($char); |
| 155 | 155 | } |
| 156 | 156 | |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | */ |
| 171 | 171 | public function stripControlCharacters(string $string) : string |
| 172 | 172 | { |
| 173 | - if(empty($string)) |
|
| 173 | + if (empty($string)) |
|
| 174 | 174 | { |
| 175 | 175 | return $string; |
| 176 | 176 | } |
@@ -178,13 +178,13 @@ discard block |
||
| 178 | 178 | $result = preg_replace(self::$controlCharsRegex, '', $string); |
| 179 | 179 | |
| 180 | 180 | // can happen if the text contains invalid UTF8 |
| 181 | - if($result === null) |
|
| 181 | + if ($result === null) |
|
| 182 | 182 | { |
| 183 | 183 | $string = ConvertHelper::string2utf8($string); |
| 184 | 184 | |
| 185 | 185 | $result = preg_replace(self::$controlCharsRegex, '', $string); |
| 186 | 186 | |
| 187 | - if($result === null) |
|
| 187 | + if ($result === null) |
|
| 188 | 188 | { |
| 189 | 189 | throw new ConvertHelper_Exception( |
| 190 | 190 | 'Cannot strip control characters: malformatted string encountered.', |
@@ -14,9 +14,9 @@ discard block |
||
| 14 | 14 | * @param mixed $value |
| 15 | 15 | * @return \AppUtils\NumberInfo |
| 16 | 16 | */ |
| 17 | -function parseNumber($value, $forceNew=false) |
|
| 17 | +function parseNumber($value, $forceNew = false) |
|
| 18 | 18 | { |
| 19 | - if($value instanceof NumberInfo && $forceNew !== true) { |
|
| 19 | + if ($value instanceof NumberInfo && $forceNew !== true) { |
|
| 20 | 20 | return $value; |
| 21 | 21 | } |
| 22 | 22 | |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | $args = func_get_args(); |
| 98 | 98 | |
| 99 | 99 | // is the localization package installed? |
| 100 | - if(class_exists('\AppLocalize\Localization')) |
|
| 100 | + if (class_exists('\AppLocalize\Localization')) |
|
| 101 | 101 | { |
| 102 | 102 | return call_user_func_array('\AppLocalize\t', $args); |
| 103 | 103 | } |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | function requireCURL() : void |
| 117 | 117 | { |
| 118 | - if(function_exists('curl_init')) { |
|
| 118 | + if (function_exists('curl_init')) { |
|
| 119 | 119 | return; |
| 120 | 120 | } |
| 121 | 121 | |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | * @param bool $initial The initial boolean value to use. |
| 133 | 133 | * @return Value_Bool |
| 134 | 134 | */ |
| 135 | -function valBool(bool $initial=false) : Value_Bool |
|
| 135 | +function valBool(bool $initial = false) : Value_Bool |
|
| 136 | 136 | { |
| 137 | 137 | return new Value_Bool($initial); |
| 138 | 138 | } |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | * @param bool $initial |
| 146 | 146 | * @return Value_Bool_True |
| 147 | 147 | */ |
| 148 | -function valBoolTrue(bool $initial=false) : Value_Bool_True |
|
| 148 | +function valBoolTrue(bool $initial = false) : Value_Bool_True |
|
| 149 | 149 | { |
| 150 | 150 | return new Value_Bool_True($initial); |
| 151 | 151 | } |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | * @param bool $initial |
| 159 | 159 | * @return Value_Bool_False |
| 160 | 160 | */ |
| 161 | -function valBoolFalse(bool $initial=true) : Value_Bool_False |
|
| 161 | +function valBoolFalse(bool $initial = true) : Value_Bool_False |
|
| 162 | 162 | { |
| 163 | 163 | return new Value_Bool_False($initial); |
| 164 | 164 | } |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | */ |
| 171 | 171 | function init() |
| 172 | 172 | { |
| 173 | - if(!class_exists('\AppLocalize\Localization')) { |
|
| 173 | + if (!class_exists('\AppLocalize\Localization')) { |
|
| 174 | 174 | return; |
| 175 | 175 | } |
| 176 | 176 | |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | { |
| 22 | 22 | protected $value = false; |
| 23 | 23 | |
| 24 | - public function __construct(bool $value=false) |
|
| 24 | + public function __construct(bool $value = false) |
|
| 25 | 25 | { |
| 26 | 26 | $this->value = $value; |
| 27 | 27 | } |