@@ -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 | // If the parameter is numeric, it will automatically |
| 203 | 203 | // be an integer, so we need the conversion here. |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | |
| 219 | 219 | $tag = $this->resolveTag($excluded, $param); |
| 220 | 220 | |
| 221 | - if(!empty($tag)) |
|
| 221 | + if (!empty($tag)) |
|
| 222 | 222 | { |
| 223 | 223 | $tokens[] = sprintf($tag, $parts); |
| 224 | 224 | } |
@@ -232,13 +232,13 @@ discard block |
||
| 232 | 232 | protected function resolveTag(array $excluded, string $paramName) : string |
| 233 | 233 | { |
| 234 | 234 | // regular, non-excluded parameter |
| 235 | - if(!isset($excluded[$paramName])) |
|
| 235 | + if (!isset($excluded[$paramName])) |
|
| 236 | 236 | { |
| 237 | 237 | return '<span class="link-param">%s</span>'; |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | // highlight excluded parameters is disabled, ignore this parameter |
| 241 | - if(!$this->info->isHighlightExcludeEnabled()) |
|
| 241 | + if (!$this->info->isHighlightExcludeEnabled()) |
|
| 242 | 242 | { |
| 243 | 243 | return ''; |
| 244 | 244 | } |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | |
| 255 | 255 | protected function render_fragment() : string |
| 256 | 256 | { |
| 257 | - if(!$this->info->hasFragment()) { |
|
| 257 | + if (!$this->info->hasFragment()) { |
|
| 258 | 258 | return ''; |
| 259 | 259 | } |
| 260 | 260 | |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | { |
| 270 | 270 | $cssFolder = realpath(__DIR__.'/../../css'); |
| 271 | 271 | |
| 272 | - if($cssFolder === false) { |
|
| 272 | + if ($cssFolder === false) { |
|
| 273 | 273 | throw new BaseException( |
| 274 | 274 | 'Cannot find package CSS folder.', |
| 275 | 275 | 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 | } |
@@ -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.', |
@@ -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 | } |
@@ -22,14 +22,14 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | class Value_Bool_False extends Value_Bool |
| 24 | 24 | { |
| 25 | - public function __construct(bool $value=true) |
|
| 25 | + public function __construct(bool $value = true) |
|
| 26 | 26 | { |
| 27 | 27 | parent::__construct($value); |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | public function set(bool $value) : Value_Bool |
| 31 | 31 | { |
| 32 | - if($value === false) |
|
| 32 | + if ($value === false) |
|
| 33 | 33 | { |
| 34 | 34 | parent::set($value); |
| 35 | 35 | } |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | { |
| 25 | 25 | public function set(bool $value) : Value_Bool |
| 26 | 26 | { |
| 27 | - if($value === true) |
|
| 27 | + if ($value === true) |
|
| 28 | 28 | { |
| 29 | 29 | parent::set($value); |
| 30 | 30 | } |
@@ -13,15 +13,15 @@ |
||
| 13 | 13 | return print_r($result, true); |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | - protected function traverseArray(array $array, int $level=0) : array |
|
| 16 | + protected function traverseArray(array $array, int $level = 0) : array |
|
| 17 | 17 | { |
| 18 | 18 | $result = array(); |
| 19 | 19 | |
| 20 | - foreach($array as $key => $val) |
|
| 20 | + foreach ($array as $key => $val) |
|
| 21 | 21 | { |
| 22 | - if(is_array($val)) |
|
| 22 | + if (is_array($val)) |
|
| 23 | 23 | { |
| 24 | - $result[$key] = $this->traverseArray($val, ($level+1)); |
|
| 24 | + $result[$key] = $this->traverseArray($val, ($level + 1)); |
|
| 25 | 25 | } |
| 26 | 26 | else |
| 27 | 27 | { |
@@ -22,8 +22,7 @@ |
||
| 22 | 22 | if(is_array($val)) |
| 23 | 23 | { |
| 24 | 24 | $result[$key] = $this->traverseArray($val, ($level+1)); |
| 25 | - } |
|
| 26 | - else |
|
| 25 | + } else |
|
| 27 | 26 | { |
| 28 | 27 | $result[$key] = parseVariable($val)->toString(); |
| 29 | 28 | } |
@@ -23,37 +23,37 @@ |
||
| 23 | 23 | { |
| 24 | 24 | const ERROR_NOT_LOADED_YET = 56501; |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * @var \SimpleXMLElement|NULL |
|
| 28 | - */ |
|
| 26 | + /** |
|
| 27 | + * @var \SimpleXMLElement|NULL |
|
| 28 | + */ |
|
| 29 | 29 | private $element = null; |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * @var XMLHelper_SimpleXML_Error[] |
|
| 33 | - */ |
|
| 31 | + /** |
|
| 32 | + * @var XMLHelper_SimpleXML_Error[] |
|
| 33 | + */ |
|
| 34 | 34 | private $errors = array(); |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Creates a simplexml instance from an XML string. |
|
| 38 | - * |
|
| 39 | - * NOTE: returns false in case of a fatal error. |
|
| 40 | - * |
|
| 41 | - * @param string $string |
|
| 42 | - * @return \SimpleXMLElement|NULL |
|
| 43 | - */ |
|
| 36 | + /** |
|
| 37 | + * Creates a simplexml instance from an XML string. |
|
| 38 | + * |
|
| 39 | + * NOTE: returns false in case of a fatal error. |
|
| 40 | + * |
|
| 41 | + * @param string $string |
|
| 42 | + * @return \SimpleXMLElement|NULL |
|
| 43 | + */ |
|
| 44 | 44 | public function loadString(string $string) : ?\SimpleXMLElement |
| 45 | 45 | { |
| 46 | 46 | return $this->load('string', $string); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * Creates a simplexml instance from an XML file. |
|
| 51 | - * |
|
| 52 | - * NOTE: returns false in case of a fatal error. |
|
| 53 | - * |
|
| 54 | - * @param string $file |
|
| 55 | - * @return \SimpleXMLElement|NULL |
|
| 56 | - */ |
|
| 49 | + /** |
|
| 50 | + * Creates a simplexml instance from an XML file. |
|
| 51 | + * |
|
| 52 | + * NOTE: returns false in case of a fatal error. |
|
| 53 | + * |
|
| 54 | + * @param string $file |
|
| 55 | + * @return \SimpleXMLElement|NULL |
|
| 56 | + */ |
|
| 57 | 57 | public function loadFile(string $file) : ?\SimpleXMLElement |
| 58 | 58 | { |
| 59 | 59 | return $this->load('file', $file); |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | // error wrappers. |
| 84 | 84 | $errors = libxml_get_errors(); |
| 85 | 85 | |
| 86 | - foreach($errors as $error) |
|
| 86 | + foreach ($errors as $error) |
|
| 87 | 87 | { |
| 88 | 88 | $this->errors[] = new XMLHelper_SimpleXML_Error($this, $error); |
| 89 | 89 | } |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | |
| 98 | 98 | $xml = $function($subject); |
| 99 | 99 | |
| 100 | - if($xml instanceof \SimpleXMLElement) |
|
| 100 | + if ($xml instanceof \SimpleXMLElement) |
|
| 101 | 101 | { |
| 102 | 102 | return $xml; |
| 103 | 103 | } |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | public function getConverter() : XMLHelper_Converter |
| 109 | 109 | { |
| 110 | - if($this->element instanceof \SimpleXMLElement) |
|
| 110 | + if ($this->element instanceof \SimpleXMLElement) |
|
| 111 | 111 | { |
| 112 | 112 | return XMLHelper::convertElement($this->element); |
| 113 | 113 | } |