@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | $this->bytes = $bytes; |
| 34 | 34 | |
| 35 | 35 | // correct negative values |
| 36 | - if($this->bytes < 0) |
|
| 36 | + if ($this->bytes < 0) |
|
| 37 | 37 | { |
| 38 | 38 | $this->bytes = 0; |
| 39 | 39 | } |
@@ -49,19 +49,19 @@ discard block |
||
| 49 | 49 | { |
| 50 | 50 | $sizes = $this->getSizesSorted($base); |
| 51 | 51 | |
| 52 | - if($this->bytes >= $sizes[0]->getBytes()) |
|
| 52 | + if ($this->bytes >= $sizes[0]->getBytes()) |
|
| 53 | 53 | { |
| 54 | 54 | $total = count($sizes); |
| 55 | 55 | |
| 56 | - for($i=0; $i < $total; $i++) |
|
| 56 | + for ($i = 0; $i < $total; $i++) |
|
| 57 | 57 | { |
| 58 | 58 | $size = $sizes[$i]; |
| 59 | 59 | |
| 60 | - if(!isset($sizes[($i+1)])) { |
|
| 60 | + if (!isset($sizes[($i + 1)])) { |
|
| 61 | 61 | return $size; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - if($this->bytes >= $size->getBytes() && $this->bytes < $sizes[($i+1)]->getBytes()) { |
|
| 64 | + if ($this->bytes >= $size->getBytes() && $this->bytes < $sizes[($i + 1)]->getBytes()) { |
|
| 65 | 65 | return $size; |
| 66 | 66 | } |
| 67 | 67 | } |
@@ -99,11 +99,11 @@ discard block |
||
| 99 | 99 | * @see ConvertHelper_StorageSizeEnum::BASE_10 |
| 100 | 100 | * @see ConvertHelper_StorageSizeEnum::BASE_2 |
| 101 | 101 | */ |
| 102 | - public function toString(int $precision, int $base=ConvertHelper_StorageSizeEnum::BASE_10) : string |
|
| 102 | + public function toString(int $precision, int $base = ConvertHelper_StorageSizeEnum::BASE_10) : string |
|
| 103 | 103 | { |
| 104 | 104 | $size = $this->detectSize($base); |
| 105 | 105 | |
| 106 | - return round($this->bytes / $size->getBytes(), $precision) . ' ' . $size->getSuffix(); |
|
| 106 | + return round($this->bytes / $size->getBytes(), $precision).' '.$size->getSuffix(); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | * @param int $precision Amount of decimals (rounded up) |
| 127 | 127 | * @return float |
| 128 | 128 | */ |
| 129 | - public function toKilobytes(int $precision=1) : float |
|
| 129 | + public function toKilobytes(int $precision = 1) : float |
|
| 130 | 130 | { |
| 131 | 131 | return $this->toNumber($precision, 'kb'); |
| 132 | 132 | } |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | * @param int $precision Amount of decimals (rounded up) |
| 138 | 138 | * @return float |
| 139 | 139 | */ |
| 140 | - public function toMegabytes(int $precision=1) : float |
|
| 140 | + public function toMegabytes(int $precision = 1) : float |
|
| 141 | 141 | { |
| 142 | 142 | return $this->toNumber($precision, 'mb'); |
| 143 | 143 | } |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | * @param int $precision Amount of decimals (rounded up) |
| 149 | 149 | * @return float |
| 150 | 150 | */ |
| 151 | - public function toGigabytes(int $precision=1) : float |
|
| 151 | + public function toGigabytes(int $precision = 1) : float |
|
| 152 | 152 | { |
| 153 | 153 | return $this->toNumber($precision, 'gb'); |
| 154 | 154 | } |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | * @param int $precision Amount of decimals (rounded up) |
| 160 | 160 | * @return float |
| 161 | 161 | */ |
| 162 | - public function toTerabytes(int $precision=1) : float |
|
| 162 | + public function toTerabytes(int $precision = 1) : float |
|
| 163 | 163 | { |
| 164 | 164 | return $this->toNumber($precision, 'tb'); |
| 165 | 165 | } |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | * @param int $precision Amount of decimals (rounded up) |
| 171 | 171 | * @return float |
| 172 | 172 | */ |
| 173 | - public function toPetabytes(int $precision=1) : float |
|
| 173 | + public function toPetabytes(int $precision = 1) : float |
|
| 174 | 174 | { |
| 175 | 175 | return $this->toNumber($precision, 'pb'); |
| 176 | 176 | } |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | * @param int $precision Amount of decimals (rounded up) |
| 182 | 182 | * @return float |
| 183 | 183 | */ |
| 184 | - public function toKibibytes(int $precision=1) : float |
|
| 184 | + public function toKibibytes(int $precision = 1) : float |
|
| 185 | 185 | { |
| 186 | 186 | return $this->toNumber($precision, 'kib'); |
| 187 | 187 | } |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | * @param int $precision Amount of decimals (rounded up) |
| 193 | 193 | * @return float |
| 194 | 194 | */ |
| 195 | - public function toMebibytes(int $precision=1) : float |
|
| 195 | + public function toMebibytes(int $precision = 1) : float |
|
| 196 | 196 | { |
| 197 | 197 | return $this->toNumber($precision, 'mib'); |
| 198 | 198 | } |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | * @param int $precision Amount of decimals (rounded up) |
| 204 | 204 | * @return float |
| 205 | 205 | */ |
| 206 | - public function toGibibytes(int $precision=1) : float |
|
| 206 | + public function toGibibytes(int $precision = 1) : float |
|
| 207 | 207 | { |
| 208 | 208 | return $this->toNumber($precision, 'gib'); |
| 209 | 209 | } |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | * @param int $precision Amount of decimals (rounded up) |
| 215 | 215 | * @return float |
| 216 | 216 | */ |
| 217 | - public function toTebibytes(int $precision=1) : float |
|
| 217 | + public function toTebibytes(int $precision = 1) : float |
|
| 218 | 218 | { |
| 219 | 219 | return $this->toNumber($precision, 'tib'); |
| 220 | 220 | } |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | * @param int $precision Amount of decimals (rounded up) |
| 226 | 226 | * @return float |
| 227 | 227 | */ |
| 228 | - public function toPebibytes(int $precision=1) : float |
|
| 228 | + public function toPebibytes(int $precision = 1) : float |
|
| 229 | 229 | { |
| 230 | 230 | return $this->toNumber($precision, 'pib'); |
| 231 | 231 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | protected static function init() |
| 46 | 46 | { |
| 47 | - if(isset(self::$sizes)) { |
|
| 47 | + if (isset(self::$sizes)) { |
|
| 48 | 48 | return; |
| 49 | 49 | } |
| 50 | 50 | |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | self::addSize('b', 1, 1, t('B'), t('Byte'), t('Bytes')); |
| 66 | 66 | |
| 67 | - if(class_exists('AppLocalize\Localization')) |
|
| 67 | + if (class_exists('AppLocalize\Localization')) |
|
| 68 | 68 | { |
| 69 | 69 | \AppLocalize\Localization::onLocaleChanged(array(self::class, 'handle_localeChanged')); |
| 70 | 70 | } |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | |
| 133 | 133 | $name = strtolower($name); |
| 134 | 134 | |
| 135 | - if(isset(self::$sizes[$name])) { |
|
| 135 | + if (isset(self::$sizes[$name])) { |
|
| 136 | 136 | return self::$sizes[$name]; |
| 137 | 137 | } |
| 138 | 138 | |
@@ -174,9 +174,9 @@ discard block |
||
| 174 | 174 | |
| 175 | 175 | $result = array(); |
| 176 | 176 | |
| 177 | - foreach(self::$sizes as $size) |
|
| 177 | + foreach (self::$sizes as $size) |
|
| 178 | 178 | { |
| 179 | - if($size->getBase() === $base) { |
|
| 179 | + if ($size->getBase() === $base) { |
|
| 180 | 180 | $result[] = $size; |
| 181 | 181 | } |
| 182 | 182 | } |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | * @return string |
| 100 | 100 | * @see ConvertHelper::bytes2readable() |
| 101 | 101 | */ |
| 102 | - public function toString(int $precision=1) : string |
|
| 102 | + public function toString(int $precision = 1) : string |
|
| 103 | 103 | { |
| 104 | 104 | return ConvertHelper::bytes2readable($this->bytes, $precision, $this->getBase()); |
| 105 | 105 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | */ |
| 111 | 111 | public function getBase() : int |
| 112 | 112 | { |
| 113 | - if($this->isValid()) { |
|
| 113 | + if ($this->isValid()) { |
|
| 114 | 114 | return $this->sizeDefinition->getBase(); |
| 115 | 115 | } |
| 116 | 116 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | public function getSizeDefinition() : ?ConvertHelper_StorageSizeEnum_Size |
| 128 | 128 | { |
| 129 | - if($this->isValid()) { |
|
| 129 | + if ($this->isValid()) { |
|
| 130 | 130 | return $this->sizeDefinition; |
| 131 | 131 | } |
| 132 | 132 | |
@@ -175,18 +175,18 @@ discard block |
||
| 175 | 175 | |
| 176 | 176 | protected function parseSize() : void |
| 177 | 177 | { |
| 178 | - if(!$this->detectParts()) { |
|
| 178 | + if (!$this->detectParts()) { |
|
| 179 | 179 | return; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | // we detected units in the string: all good. |
| 183 | - if($this->units !== null) |
|
| 183 | + if ($this->units !== null) |
|
| 184 | 184 | { |
| 185 | 185 | return; |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | // just a numeric value: we assume this means we're dealing with bytes. |
| 189 | - if(is_numeric($this->number)) |
|
| 189 | + if (is_numeric($this->number)) |
|
| 190 | 190 | { |
| 191 | 191 | $this->units = 'b'; |
| 192 | 192 | return; |
@@ -212,12 +212,12 @@ discard block |
||
| 212 | 212 | |
| 213 | 213 | $number = $this->sizeString; |
| 214 | 214 | |
| 215 | - foreach($units as $unit) |
|
| 215 | + foreach ($units as $unit) |
|
| 216 | 216 | { |
| 217 | - if(stristr($number, $unit)) |
|
| 217 | + if (stristr($number, $unit)) |
|
| 218 | 218 | { |
| 219 | 219 | // there are more than 1 unit defined in the string |
| 220 | - if($this->units !== null) |
|
| 220 | + if ($this->units !== null) |
|
| 221 | 221 | { |
| 222 | 222 | $this->setError( |
| 223 | 223 | t( |
@@ -273,14 +273,14 @@ discard block |
||
| 273 | 273 | { |
| 274 | 274 | $this->parseSize(); |
| 275 | 275 | |
| 276 | - if(!$this->valid) { |
|
| 276 | + if (!$this->valid) { |
|
| 277 | 277 | return; |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | $int = intval($this->number); |
| 281 | 281 | |
| 282 | 282 | // negative values |
| 283 | - if($int < 0) |
|
| 283 | + if ($int < 0) |
|
| 284 | 284 | { |
| 285 | 285 | $this->setError( |
| 286 | 286 | t('Negative values cannot be used as size.'), |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | $this->parse(); |
| 61 | 61 | |
| 62 | - if(!$this->detectType()) { |
|
| 62 | + if (!$this->detectType()) { |
|
| 63 | 63 | $this->validate(); |
| 64 | 64 | } |
| 65 | 65 | } |
@@ -93,11 +93,11 @@ discard block |
||
| 93 | 93 | 'phoneLink' |
| 94 | 94 | ); |
| 95 | 95 | |
| 96 | - foreach($types as $type) |
|
| 96 | + foreach ($types as $type) |
|
| 97 | 97 | { |
| 98 | 98 | $method = 'detectType_'.$type; |
| 99 | 99 | |
| 100 | - if($this->$method() === true) |
|
| 100 | + if ($this->$method() === true) |
|
| 101 | 101 | { |
| 102 | 102 | $this->isValid = true; |
| 103 | 103 | return true; |
@@ -115,11 +115,11 @@ discard block |
||
| 115 | 115 | 'hostIsPresent' |
| 116 | 116 | ); |
| 117 | 117 | |
| 118 | - foreach($validations as $validation) |
|
| 118 | + foreach ($validations as $validation) |
|
| 119 | 119 | { |
| 120 | 120 | $method = 'validate_'.$validation; |
| 121 | 121 | |
| 122 | - if($this->$method() !== true) { |
|
| 122 | + if ($this->$method() !== true) { |
|
| 123 | 123 | return; |
| 124 | 124 | } |
| 125 | 125 | } |
@@ -132,13 +132,13 @@ discard block |
||
| 132 | 132 | // every link needs a host. This case can happen for ex, if |
| 133 | 133 | // the link starts with a typo with only one slash, like: |
| 134 | 134 | // "http:/hostname" |
| 135 | - if(isset($this->info['host'])) { |
|
| 135 | + if (isset($this->info['host'])) { |
|
| 136 | 136 | return true; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | $this->setError( |
| 140 | 140 | URLInfo::ERROR_MISSING_HOST, |
| 141 | - t('Cannot determine the link\'s host name.') . ' ' . |
|
| 141 | + t('Cannot determine the link\'s host name.').' '. |
|
| 142 | 142 | t('This usually happens when there\'s a typo somewhere.') |
| 143 | 143 | ); |
| 144 | 144 | |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | |
| 148 | 148 | protected function validate_schemeIsSet() : bool |
| 149 | 149 | { |
| 150 | - if(isset($this->info['scheme'])) { |
|
| 150 | + if (isset($this->info['scheme'])) { |
|
| 151 | 151 | return true; |
| 152 | 152 | } |
| 153 | 153 | |
@@ -164,13 +164,13 @@ discard block |
||
| 164 | 164 | |
| 165 | 165 | protected function validate_schemeIsKnown() : bool |
| 166 | 166 | { |
| 167 | - if(in_array($this->info['scheme'], $this->knownSchemes)) { |
|
| 167 | + if (in_array($this->info['scheme'], $this->knownSchemes)) { |
|
| 168 | 168 | return true; |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | $this->setError( |
| 172 | 172 | URLInfo::ERROR_INVALID_SCHEME, |
| 173 | - t('The scheme %1$s is not supported for links.', $this->info['scheme']) . ' ' . |
|
| 173 | + t('The scheme %1$s is not supported for links.', $this->info['scheme']).' '. |
|
| 174 | 174 | t('Valid schemes are: %1$s.', implode(', ', $this->knownSchemes)) |
| 175 | 175 | ); |
| 176 | 176 | |
@@ -184,9 +184,9 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | protected function filterParsed() |
| 186 | 186 | { |
| 187 | - foreach($this->info as $key => $val) |
|
| 187 | + foreach ($this->info as $key => $val) |
|
| 188 | 188 | { |
| 189 | - if(is_string($val)) { |
|
| 189 | + if (is_string($val)) { |
|
| 190 | 190 | $this->info[$key] = trim($val); |
| 191 | 191 | } |
| 192 | 192 | } |
@@ -194,15 +194,15 @@ discard block |
||
| 194 | 194 | $this->info['params'] = array(); |
| 195 | 195 | $this->info['type'] = URLInfo::TYPE_URL; |
| 196 | 196 | |
| 197 | - if(isset($this->info['host'])) { |
|
| 197 | + if (isset($this->info['host'])) { |
|
| 198 | 198 | $this->info['host'] = str_replace(' ', '', $this->info['host']); |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - if(isset($this->info['path'])) { |
|
| 201 | + if (isset($this->info['path'])) { |
|
| 202 | 202 | $this->info['path'] = str_replace(' ', '', $this->info['path']); |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - if(isset($this->info['query']) && !empty($this->info['query'])) |
|
| 205 | + if (isset($this->info['query']) && !empty($this->info['query'])) |
|
| 206 | 206 | { |
| 207 | 207 | $this->info['params'] = \AppUtils\ConvertHelper::parseQueryString($this->info['query']); |
| 208 | 208 | ksort($this->info['params']); |
@@ -211,12 +211,12 @@ discard block |
||
| 211 | 211 | |
| 212 | 212 | protected function detectType_email() : bool |
| 213 | 213 | { |
| 214 | - if(isset($this->info['scheme']) && $this->info['scheme'] == 'mailto') { |
|
| 214 | + if (isset($this->info['scheme']) && $this->info['scheme'] == 'mailto') { |
|
| 215 | 215 | $this->info['type'] = URLInfo::TYPE_EMAIL; |
| 216 | 216 | return true; |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - if(isset($this->info['path']) && preg_match(\AppUtils\RegexHelper::REGEX_EMAIL, $this->info['path'])) |
|
| 219 | + if (isset($this->info['path']) && preg_match(\AppUtils\RegexHelper::REGEX_EMAIL, $this->info['path'])) |
|
| 220 | 220 | { |
| 221 | 221 | $this->info['scheme'] = 'mailto'; |
| 222 | 222 | $this->info['type'] = URLInfo::TYPE_EMAIL; |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | |
| 229 | 229 | protected function detectType_fragmentLink() : bool |
| 230 | 230 | { |
| 231 | - if(isset($this->info['fragment']) && !isset($this->info['scheme'])) { |
|
| 231 | + if (isset($this->info['fragment']) && !isset($this->info['scheme'])) { |
|
| 232 | 232 | $this->info['type'] = URLInfo::TYPE_FRAGMENT; |
| 233 | 233 | return true; |
| 234 | 234 | } |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | |
| 239 | 239 | protected function detectType_phoneLink() : bool |
| 240 | 240 | { |
| 241 | - if(isset($this->info['scheme']) && $this->info['scheme'] == 'tel') { |
|
| 241 | + if (isset($this->info['scheme']) && $this->info['scheme'] == 'tel') { |
|
| 242 | 242 | $this->info['type'] = URLInfo::TYPE_PHONE; |
| 243 | 243 | return true; |
| 244 | 244 | } |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | |
| 264 | 264 | public function getErrorMessage() : string |
| 265 | 265 | { |
| 266 | - if(isset($this->error)) { |
|
| 266 | + if (isset($this->error)) { |
|
| 267 | 267 | return $this->error['message']; |
| 268 | 268 | } |
| 269 | 269 | |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | |
| 273 | 273 | public function getErrorCode() : int |
| 274 | 274 | { |
| 275 | - if(isset($this->error)) { |
|
| 275 | + if (isset($this->error)) { |
|
| 276 | 276 | return $this->error['code']; |
| 277 | 277 | } |
| 278 | 278 | |
@@ -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 | |
@@ -162,19 +162,19 @@ discard block |
||
| 162 | 162 | { |
| 163 | 163 | $params = $this->info->getParams(); |
| 164 | 164 | |
| 165 | - if(empty($params)) { |
|
| 165 | + if (empty($params)) { |
|
| 166 | 166 | return ''; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | $tokens = array(); |
| 170 | 170 | $excluded = array(); |
| 171 | 171 | |
| 172 | - if($this->info->isParamExclusionEnabled()) |
|
| 172 | + if ($this->info->isParamExclusionEnabled()) |
|
| 173 | 173 | { |
| 174 | 174 | $excluded = $this->info->getExcludedParams(); |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - foreach($params as $param => $value) |
|
| 177 | + foreach ($params as $param => $value) |
|
| 178 | 178 | { |
| 179 | 179 | $parts = sprintf( |
| 180 | 180 | '<span class="link-param-name">%s</span>'. |
@@ -192,10 +192,10 @@ discard block |
||
| 192 | 192 | $tag = ''; |
| 193 | 193 | |
| 194 | 194 | // is parameter exclusion enabled, and is this an excluded parameter? |
| 195 | - if(isset($excluded[$param])) |
|
| 195 | + if (isset($excluded[$param])) |
|
| 196 | 196 | { |
| 197 | 197 | // display the excluded parameter, but highlight it |
| 198 | - if($this->info->isHighlightExcludeEnabled()) |
|
| 198 | + if ($this->info->isHighlightExcludeEnabled()) |
|
| 199 | 199 | { |
| 200 | 200 | $tooltip = $excluded[$param]; |
| 201 | 201 | |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | |
| 229 | 229 | protected function render_fragment() : string |
| 230 | 230 | { |
| 231 | - if(!$this->info->hasFragment()) { |
|
| 231 | + if (!$this->info->hasFragment()) { |
|
| 232 | 232 | return ''; |
| 233 | 233 | } |
| 234 | 234 | |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | { |
| 244 | 244 | $cssFolder = realpath(__DIR__.'/../../css'); |
| 245 | 245 | |
| 246 | - if($cssFolder === false) { |
|
| 246 | + if ($cssFolder === false) { |
|
| 247 | 247 | throw new BaseException( |
| 248 | 248 | 'Cannot find package CSS folder.', |
| 249 | 249 | null, |
@@ -56,16 +56,16 @@ |
||
| 56 | 56 | { |
| 57 | 57 | $normalized = $this->info->getScheme().'://'.$this->info->getHost(); |
| 58 | 58 | |
| 59 | - if($this->info->hasPath()) { |
|
| 59 | + if ($this->info->hasPath()) { |
|
| 60 | 60 | $normalized .= $this->info->getPath(); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | $params = $this->info->getParams(); |
| 64 | - if(!empty($params)) { |
|
| 64 | + if (!empty($params)) { |
|
| 65 | 65 | $normalized .= '?'.http_build_query($params); |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - if($this->info->hasFragment()) { |
|
| 68 | + if ($this->info->hasFragment()) { |
|
| 69 | 69 | $normalized .= '#'.$this->info->getFragment(); |
| 70 | 70 | } |
| 71 | 71 | |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | { |
| 47 | 47 | $result = array(); |
| 48 | 48 | |
| 49 | - foreach($this->headers as $header) |
|
| 49 | + foreach ($this->headers as $header) |
|
| 50 | 50 | { |
| 51 | 51 | $result[] = $header['type']; |
| 52 | 52 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | { |
| 62 | 62 | // we may be in a CLI environment where the headers |
| 63 | 63 | // are not populated. |
| 64 | - if(!isset($_SERVER['HTTP_ACCEPT'])) { |
|
| 64 | + if (!isset($_SERVER['HTTP_ACCEPT'])) { |
|
| 65 | 65 | return; |
| 66 | 66 | } |
| 67 | 67 | |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | $accept = array(); |
| 81 | 81 | |
| 82 | - foreach($tokens as $i => $term) |
|
| 82 | + foreach ($tokens as $i => $term) |
|
| 83 | 83 | { |
| 84 | 84 | $accept[] = $this->parseEntry($i, $term); |
| 85 | 85 | } |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | 'type' => null |
| 106 | 106 | ); |
| 107 | 107 | |
| 108 | - if(strstr($mime, ';')) |
|
| 108 | + if (strstr($mime, ';')) |
|
| 109 | 109 | { |
| 110 | 110 | $parts = explode(';', $mime); |
| 111 | 111 | $mime = array_shift($parts); |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | // like an URL query string if separated by ampersands; |
| 115 | 115 | $entry['params'] = ConvertHelper::parseQueryString(implode('&', $parts)); |
| 116 | 116 | |
| 117 | - if(isset($entry['params']['q'])) |
|
| 117 | + if (isset($entry['params']['q'])) |
|
| 118 | 118 | { |
| 119 | 119 | $entry['quality'] = (double)$entry['params']['q']; |
| 120 | 120 | } |
@@ -90,11 +90,11 @@ discard block |
||
| 90 | 90 | public function getParam($name, $default = null) |
| 91 | 91 | { |
| 92 | 92 | $value = $default; |
| 93 | - if(isset($_REQUEST[$name])) { |
|
| 93 | + if (isset($_REQUEST[$name])) { |
|
| 94 | 94 | $value = $_REQUEST[$name]; |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - if(isset($this->knownParams[$name])) { |
|
| 97 | + if (isset($this->knownParams[$name])) { |
|
| 98 | 98 | $value = $this->knownParams[$name]->validate($value); |
| 99 | 99 | } |
| 100 | 100 | |
@@ -143,9 +143,9 @@ discard block |
||
| 143 | 143 | |
| 144 | 144 | $exclude = array_merge($exclude, $this->getExcludeParams()); |
| 145 | 145 | |
| 146 | - foreach($exclude as $name) |
|
| 146 | + foreach ($exclude as $name) |
|
| 147 | 147 | { |
| 148 | - if(isset($vars[$name])) |
|
| 148 | + if (isset($vars[$name])) |
|
| 149 | 149 | { |
| 150 | 150 | unset($vars[$name]); |
| 151 | 151 | } |
@@ -156,9 +156,9 @@ discard block |
||
| 156 | 156 | // remove the HTML_QuickForm2 form variable if present, to |
| 157 | 157 | // avoid redirect loops when using the refresh URL in |
| 158 | 158 | // a page in which a form has been submitted. |
| 159 | - foreach($names as $name) |
|
| 159 | + foreach ($names as $name) |
|
| 160 | 160 | { |
| 161 | - if(strstr($name, '_qf__')) |
|
| 161 | + if (strstr($name, '_qf__')) |
|
| 162 | 162 | { |
| 163 | 163 | unset($vars[$name]); |
| 164 | 164 | break; |
@@ -186,13 +186,13 @@ discard block |
||
| 186 | 186 | * @param string $dispatcher Relative path to script to use for the URL. Append trailing slash if needed. |
| 187 | 187 | * @return string |
| 188 | 188 | */ |
| 189 | - public function buildURL($params = array(), string $dispatcher='') |
|
| 189 | + public function buildURL($params = array(), string $dispatcher = '') |
|
| 190 | 190 | { |
| 191 | - $url = rtrim($this->getBaseURL(), '/') . '/' . $dispatcher; |
|
| 191 | + $url = rtrim($this->getBaseURL(), '/').'/'.$dispatcher; |
|
| 192 | 192 | |
| 193 | 193 | // append any leftover parameters to the end of the URL |
| 194 | 194 | if (!empty($params)) { |
| 195 | - $url .= '?' . http_build_query($params, null, '&'); |
|
| 195 | + $url .= '?'.http_build_query($params, null, '&'); |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | return $url; |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | */ |
| 224 | 224 | public function registerParam($name) |
| 225 | 225 | { |
| 226 | - if(!isset($this->knownParams[$name])) { |
|
| 226 | + if (!isset($this->knownParams[$name])) { |
|
| 227 | 227 | $param = new Request_Param($this, $name); |
| 228 | 228 | $this->knownParams[$name] = $param; |
| 229 | 229 | } |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | */ |
| 241 | 241 | public function getRegisteredParam(string $name) : Request_Param |
| 242 | 242 | { |
| 243 | - if(isset($this->knownParams[$name])) { |
|
| 243 | + if (isset($this->knownParams[$name])) { |
|
| 244 | 244 | return $this->knownParams[$name]; |
| 245 | 245 | } |
| 246 | 246 | |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | { |
| 301 | 301 | static $accept; |
| 302 | 302 | |
| 303 | - if(!isset($accept)) { |
|
| 303 | + if (!isset($accept)) { |
|
| 304 | 304 | $accept = new Request_AcceptHeaders(); |
| 305 | 305 | } |
| 306 | 306 | |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | { |
| 320 | 320 | $_REQUEST[$name] = $value; |
| 321 | 321 | |
| 322 | - if(isset($this->knownParams[$name])) { |
|
| 322 | + if (isset($this->knownParams[$name])) { |
|
| 323 | 323 | unset($this->knownParams[$name]); |
| 324 | 324 | } |
| 325 | 325 | |
@@ -353,11 +353,11 @@ discard block |
||
| 353 | 353 | */ |
| 354 | 354 | public function removeParam(string $name) : Request |
| 355 | 355 | { |
| 356 | - if(isset($_REQUEST[$name])) { |
|
| 356 | + if (isset($_REQUEST[$name])) { |
|
| 357 | 357 | unset($_REQUEST[$name]); |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | - if(isset($this->knownParams[$name])) { |
|
| 360 | + if (isset($this->knownParams[$name])) { |
|
| 361 | 361 | unset($this->knownParams[$name]); |
| 362 | 362 | } |
| 363 | 363 | |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | */ |
| 373 | 373 | public function removeParams(array $names) : Request |
| 374 | 374 | { |
| 375 | - foreach($names as $name) { |
|
| 375 | + foreach ($names as $name) { |
|
| 376 | 376 | $this->removeParam($name); |
| 377 | 377 | } |
| 378 | 378 | |
@@ -388,10 +388,10 @@ discard block |
||
| 388 | 388 | * @param string $name |
| 389 | 389 | * @return bool |
| 390 | 390 | */ |
| 391 | - public function getBool($name, $default=false) |
|
| 391 | + public function getBool($name, $default = false) |
|
| 392 | 392 | { |
| 393 | 393 | $value = $this->getParam($name, $default); |
| 394 | - if(ConvertHelper::isBoolean($value)) { |
|
| 394 | + if (ConvertHelper::isBoolean($value)) { |
|
| 395 | 395 | return ConvertHelper::string2bool($value); |
| 396 | 396 | } |
| 397 | 397 | |
@@ -400,11 +400,11 @@ discard block |
||
| 400 | 400 | |
| 401 | 401 | public function validate() |
| 402 | 402 | { |
| 403 | - foreach($this->knownParams as $param) |
|
| 403 | + foreach ($this->knownParams as $param) |
|
| 404 | 404 | { |
| 405 | 405 | $name = $param->getName(); |
| 406 | 406 | |
| 407 | - if($param->isRequired() && !$this->hasParam($name)) |
|
| 407 | + if ($param->isRequired() && !$this->hasParam($name)) |
|
| 408 | 408 | { |
| 409 | 409 | throw new Request_Exception( |
| 410 | 410 | 'Missing request parameter '.$name, |
@@ -426,10 +426,10 @@ discard block |
||
| 426 | 426 | * @param mixed $default |
| 427 | 427 | * @return string |
| 428 | 428 | */ |
| 429 | - public function getFilteredParam($name, $default=null) |
|
| 429 | + public function getFilteredParam($name, $default = null) |
|
| 430 | 430 | { |
| 431 | 431 | $val = $this->getParam($name, $default); |
| 432 | - if(is_string($val)) { |
|
| 432 | + if (is_string($val)) { |
|
| 433 | 433 | $val = htmlspecialchars(trim(strip_tags($val)), ENT_QUOTES, 'UTF-8'); |
| 434 | 434 | } |
| 435 | 435 | |
@@ -448,24 +448,24 @@ discard block |
||
| 448 | 448 | * @see Request::getJSONAssoc() |
| 449 | 449 | * @see Request::getJSONObject() |
| 450 | 450 | */ |
| 451 | - public function getJSON(string $name, bool $assoc=true) |
|
| 451 | + public function getJSON(string $name, bool $assoc = true) |
|
| 452 | 452 | { |
| 453 | 453 | $value = $this->getParam($name); |
| 454 | 454 | |
| 455 | - if(!empty($value) && is_string($value)) |
|
| 455 | + if (!empty($value) && is_string($value)) |
|
| 456 | 456 | { |
| 457 | 457 | $data = json_decode($value, $assoc); |
| 458 | 458 | |
| 459 | - if($assoc && is_array($data)) { |
|
| 459 | + if ($assoc && is_array($data)) { |
|
| 460 | 460 | return $data; |
| 461 | 461 | } |
| 462 | 462 | |
| 463 | - if(is_object($data)) { |
|
| 463 | + if (is_object($data)) { |
|
| 464 | 464 | return $data; |
| 465 | 465 | } |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | - if($assoc) { |
|
| 468 | + if ($assoc) { |
|
| 469 | 469 | return array(); |
| 470 | 470 | } |
| 471 | 471 | |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | public function getJSONAssoc(string $name) : array |
| 483 | 483 | { |
| 484 | 484 | $result = $this->getJSON($name); |
| 485 | - if(is_array($result)) { |
|
| 485 | + if (is_array($result)) { |
|
| 486 | 486 | return $result; |
| 487 | 487 | } |
| 488 | 488 | |
@@ -499,7 +499,7 @@ discard block |
||
| 499 | 499 | public function getJSONObject(string $name) : object |
| 500 | 500 | { |
| 501 | 501 | $result = $this->getJSON($name, false); |
| 502 | - if(is_object($result)) { |
|
| 502 | + if (is_object($result)) { |
|
| 503 | 503 | return $result; |
| 504 | 504 | } |
| 505 | 505 | |
@@ -512,10 +512,10 @@ discard block |
||
| 512 | 512 | * @param array|string $data |
| 513 | 513 | * @param bool $exit Whether to exit the script afterwards. |
| 514 | 514 | */ |
| 515 | - public static function sendJSON($data, bool $exit=true) |
|
| 515 | + public static function sendJSON($data, bool $exit = true) |
|
| 516 | 516 | { |
| 517 | 517 | $payload = $data; |
| 518 | - if(!is_string($payload)) { |
|
| 518 | + if (!is_string($payload)) { |
|
| 519 | 519 | $payload = json_encode($payload); |
| 520 | 520 | } |
| 521 | 521 | |
@@ -525,7 +525,7 @@ discard block |
||
| 525 | 525 | |
| 526 | 526 | echo $payload; |
| 527 | 527 | |
| 528 | - if($exit) |
|
| 528 | + if ($exit) |
|
| 529 | 529 | { |
| 530 | 530 | exit; |
| 531 | 531 | } |
@@ -537,7 +537,7 @@ discard block |
||
| 537 | 537 | * @param string $html |
| 538 | 538 | * @param bool $exit Whether to exit the script afterwards. |
| 539 | 539 | */ |
| 540 | - public static function sendHTML(string $html, bool $exit=true) |
|
| 540 | + public static function sendHTML(string $html, bool $exit = true) |
|
| 541 | 541 | { |
| 542 | 542 | header('Cache-Control: no-cache, must-revalidate'); |
| 543 | 543 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -545,7 +545,7 @@ discard block |
||
| 545 | 545 | |
| 546 | 546 | echo $html; |
| 547 | 547 | |
| 548 | - if($exit) |
|
| 548 | + if ($exit) |
|
| 549 | 549 | { |
| 550 | 550 | exit; |
| 551 | 551 | } |
@@ -561,7 +561,7 @@ discard block |
||
| 561 | 561 | * @param array $limitParams Whether to limit the comparison to these specific parameter names (if present) |
| 562 | 562 | * @return Request_URLComparer |
| 563 | 563 | */ |
| 564 | - public function createURLComparer(string $sourceURL, string $targetURL, array $limitParams=array()) : Request_URLComparer |
|
| 564 | + public function createURLComparer(string $sourceURL, string $targetURL, array $limitParams = array()) : Request_URLComparer |
|
| 565 | 565 | { |
| 566 | 566 | $comparer = new Request_URLComparer($this, $sourceURL, $targetURL); |
| 567 | 567 | $comparer->addLimitParams($limitParams); |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | |
| 21 | 21 | protected function _filter() |
| 22 | 22 | { |
| 23 | - if($this->value === 'yes' || $this->value === 'true' || $this->value === true) { |
|
| 23 | + if ($this->value === 'yes' || $this->value === 'true' || $this->value === true) { |
|
| 24 | 24 | return true; |
| 25 | 25 | } |
| 26 | 26 | |