@@ -22,7 +22,7 @@ |
||
| 22 | 22 | { |
| 23 | 23 | $name = self::break($fullName); |
| 24 | 24 | |
| 25 | - if ($name['sobrenomes'] < 1) { |
|
| 25 | + if ($name['sobrenomes']<1) { |
|
| 26 | 26 | return false; |
| 27 | 27 | } |
| 28 | 28 | |
@@ -7,15 +7,15 @@ |
||
| 7 | 7 | * Code inspired from the SplClassLoader RFC |
| 8 | 8 | * @see https://wiki.php.net/rfc/splclassloader#example_implementation |
| 9 | 9 | */ |
| 10 | -spl_autoload_register(function ($className) { |
|
| 10 | +spl_autoload_register(function($className) { |
|
| 11 | 11 | $className = ltrim($className, '\\'); |
| 12 | 12 | $fileName = ''; |
| 13 | 13 | if ($lastNsPos = strripos($className, '\\')) { |
| 14 | 14 | $namespace = substr($className, 0, $lastNsPos); |
| 15 | - $className = substr($className, $lastNsPos + 1); |
|
| 16 | - $fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR; |
|
| 15 | + $className = substr($className, $lastNsPos+1); |
|
| 16 | + $fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace).DIRECTORY_SEPARATOR; |
|
| 17 | 17 | } |
| 18 | - $fileName = __DIR__ . DIRECTORY_SEPARATOR . $fileName . $className . '.php'; |
|
| 18 | + $fileName = __DIR__.DIRECTORY_SEPARATOR.$fileName.$className.'.php'; |
|
| 19 | 19 | if (file_exists($fileName)) { |
| 20 | 20 | require $fileName; |
| 21 | 21 | |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | public static function incluiInArray($field, $array) |
| 18 | 18 | { |
| 19 | 19 | foreach ($array as $notPermit) { |
| 20 | - if(strpos($field, $notPermit) !== false){ |
|
| 20 | + if (strpos($field, $notPermit) !== false) { |
|
| 21 | 21 | return true; |
| 22 | 22 | } |
| 23 | 23 | } |
@@ -85,8 +85,11 @@ discard block |
||
| 85 | 85 | * @return bool true on image, false on anything else |
| 86 | 86 | */ |
| 87 | 87 | public static function isImage($link) { |
| 88 | - if (preg_match('%\.(gif|jpe?g|png|bmp)$%i',$link)) return true; |
|
| 89 | - else return false; |
|
| 88 | + if (preg_match('%\.(gif|jpe?g|png|bmp)$%i',$link)) { |
|
| 89 | + return true; |
|
| 90 | + } else { |
|
| 91 | + return false; |
|
| 92 | + } |
|
| 90 | 93 | } |
| 91 | 94 | |
| 92 | 95 | /** |
@@ -143,8 +146,11 @@ discard block |
||
| 143 | 146 | * @return bool true on mailto:, false on everything else |
| 144 | 147 | */ |
| 145 | 148 | public static function isMailto($link) { |
| 146 | - if (stripos($link,'mailto:')===FALSE) return false; |
|
| 147 | - else return true; |
|
| 149 | + if (stripos($link,'mailto:')===FALSE) { |
|
| 150 | + return false; |
|
| 151 | + } else { |
|
| 152 | + return true; |
|
| 153 | + } |
|
| 148 | 154 | } |
| 149 | 155 | |
| 150 | 156 | /* Depreciated (I think) |
@@ -210,9 +216,15 @@ discard block |
||
| 210 | 216 | |
| 211 | 217 | // Copy base authority. |
| 212 | 218 | $r['host'] = $b['host']; |
| 213 | - if ( isset( $b['port'] ) ) $r['port'] = $b['port']; |
|
| 214 | - if ( isset( $b['user'] ) ) $r['user'] = $b['user']; |
|
| 215 | - if ( isset( $b['pass'] ) ) $r['pass'] = $b['pass']; |
|
| 219 | + if ( isset( $b['port'] ) ) { |
|
| 220 | + $r['port'] = $b['port']; |
|
| 221 | + } |
|
| 222 | + if ( isset( $b['user'] ) ) { |
|
| 223 | + $r['user'] = $b['user']; |
|
| 224 | + } |
|
| 225 | + if ( isset( $b['pass'] ) ) { |
|
| 226 | + $r['pass'] = $b['pass']; |
|
| 227 | + } |
|
| 216 | 228 | |
| 217 | 229 | // If relative URL has no path, use base path |
| 218 | 230 | if ( empty( $r['path'] ) ) |
@@ -232,7 +244,9 @@ discard block |
||
| 232 | 244 | if ( $r['path'][0] != '/' ) |
| 233 | 245 | { |
| 234 | 246 | $base = mb_strrchr( $b['path'], '/', TRUE, 'UTF-8' ); |
| 235 | - if ( $base === FALSE ) $base = ''; |
|
| 247 | + if ( $base === FALSE ) { |
|
| 248 | + $base = ''; |
|
| 249 | + } |
|
| 236 | 250 | $r['path'] = $base . '/' . $r['path']; |
| 237 | 251 | } |
| 238 | 252 | $r['path'] = self::urlRemoveDotSegments( $r['path'] ); |
@@ -323,41 +337,70 @@ discard block |
||
| 323 | 337 | return FALSE; |
| 324 | 338 | } |
| 325 | 339 | |
| 326 | - if ( !empty($m[2]) ) $parts['scheme'] = strtolower($m[2]); |
|
| 340 | + if ( !empty($m[2]) ) { |
|
| 341 | + $parts['scheme'] = strtolower($m[2]); |
|
| 342 | + } |
|
| 327 | 343 | |
| 328 | 344 | if ( !empty($m[7]) ) { |
| 329 | - if ( isset( $m[9] ) ) $parts['user'] = $m[9]; |
|
| 330 | - else $parts['user'] = ''; |
|
| 345 | + if ( isset( $m[9] ) ) { |
|
| 346 | + $parts['user'] = $m[9]; |
|
| 347 | + } else { |
|
| 348 | + $parts['user'] = ''; |
|
| 349 | + } |
|
| 350 | + } |
|
| 351 | + if ( !empty($m[10]) ) { |
|
| 352 | + $parts['pass'] = $m[11]; |
|
| 331 | 353 | } |
| 332 | - if ( !empty($m[10]) ) $parts['pass'] = $m[11]; |
|
| 333 | 354 | |
| 334 | - if ( !empty($m[13]) ) $h=$parts['host'] = $m[13]; |
|
| 335 | - else if ( !empty($m[14]) ) $parts['host'] = $m[14]; |
|
| 336 | - else if ( !empty($m[16]) ) $parts['host'] = $m[16]; |
|
| 337 | - else if ( !empty( $m[5] ) ) $parts['host'] = ''; |
|
| 338 | - if ( !empty($m[17]) ) $parts['port'] = $m[18]; |
|
| 355 | + if ( !empty($m[13]) ) { |
|
| 356 | + $h=$parts['host'] = $m[13]; |
|
| 357 | + } else if ( !empty($m[14]) ) { |
|
| 358 | + $parts['host'] = $m[14]; |
|
| 359 | + } else if ( !empty($m[16]) ) { |
|
| 360 | + $parts['host'] = $m[16]; |
|
| 361 | + } else if ( !empty( $m[5] ) ) { |
|
| 362 | + $parts['host'] = ''; |
|
| 363 | + } |
|
| 364 | + if ( !empty($m[17]) ) { |
|
| 365 | + $parts['port'] = $m[18]; |
|
| 366 | + } |
|
| 339 | 367 | |
| 340 | - if ( !empty($m[19]) ) $parts['path'] = $m[19]; |
|
| 341 | - else if ( !empty($m[21]) ) $parts['path'] = $m[21]; |
|
| 342 | - else if ( !empty($m[25]) ) $parts['path'] = $m[25]; |
|
| 368 | + if ( !empty($m[19]) ) { |
|
| 369 | + $parts['path'] = $m[19]; |
|
| 370 | + } else if ( !empty($m[21]) ) { |
|
| 371 | + $parts['path'] = $m[21]; |
|
| 372 | + } else if ( !empty($m[25]) ) { |
|
| 373 | + $parts['path'] = $m[25]; |
|
| 374 | + } |
|
| 343 | 375 | |
| 344 | - if ( !empty($m[27]) ) $parts['query'] = $m[28]; |
|
| 345 | - if ( !empty($m[29]) ) $parts['fragment']= $m[30]; |
|
| 376 | + if ( !empty($m[27]) ) { |
|
| 377 | + $parts['query'] = $m[28]; |
|
| 378 | + } |
|
| 379 | + if ( !empty($m[29]) ) { |
|
| 380 | + $parts['fragment']= $m[30]; |
|
| 381 | + } |
|
| 346 | 382 | |
| 347 | - if ( !$decode ) |
|
| 348 | - return $parts; |
|
| 349 | - if ( !empty($parts['user']) ) |
|
| 350 | - $parts['user'] = rawurldecode( $parts['user'] ); |
|
| 351 | - if ( !empty($parts['pass']) ) |
|
| 352 | - $parts['pass'] = rawurldecode( $parts['pass'] ); |
|
| 353 | - if ( !empty($parts['path']) ) |
|
| 354 | - $parts['path'] = rawurldecode( $parts['path'] ); |
|
| 355 | - if ( isset($h) ) |
|
| 356 | - $parts['host'] = rawurldecode( $parts['host'] ); |
|
| 357 | - if ( !empty($parts['query']) ) |
|
| 358 | - $parts['query'] = rawurldecode( $parts['query'] ); |
|
| 359 | - if ( !empty($parts['fragment']) ) |
|
| 360 | - $parts['fragment'] = rawurldecode( $parts['fragment'] ); |
|
| 383 | + if ( !$decode ) { |
|
| 384 | + return $parts; |
|
| 385 | + } |
|
| 386 | + if ( !empty($parts['user']) ) { |
|
| 387 | + $parts['user'] = rawurldecode( $parts['user'] ); |
|
| 388 | + } |
|
| 389 | + if ( !empty($parts['pass']) ) { |
|
| 390 | + $parts['pass'] = rawurldecode( $parts['pass'] ); |
|
| 391 | + } |
|
| 392 | + if ( !empty($parts['path']) ) { |
|
| 393 | + $parts['path'] = rawurldecode( $parts['path'] ); |
|
| 394 | + } |
|
| 395 | + if ( isset($h) ) { |
|
| 396 | + $parts['host'] = rawurldecode( $parts['host'] ); |
|
| 397 | + } |
|
| 398 | + if ( !empty($parts['query']) ) { |
|
| 399 | + $parts['query'] = rawurldecode( $parts['query'] ); |
|
| 400 | + } |
|
| 401 | + if ( !empty($parts['fragment']) ) { |
|
| 402 | + $parts['fragment'] = rawurldecode( $parts['fragment'] ); |
|
| 403 | + } |
|
| 361 | 404 | return $parts; |
| 362 | 405 | } |
| 363 | 406 | |
@@ -397,33 +440,44 @@ discard block |
||
| 397 | 440 | } |
| 398 | 441 | |
| 399 | 442 | $url = ''; |
| 400 | - if ( !empty( $parts['scheme'] ) ) |
|
| 401 | - $url .= $parts['scheme'] . ':'; |
|
| 443 | + if ( !empty( $parts['scheme'] ) ) { |
|
| 444 | + $url .= $parts['scheme'] . ':'; |
|
| 445 | + } |
|
| 402 | 446 | if ( isset( $parts['host'] ) ) |
| 403 | 447 | { |
| 404 | 448 | $url .= '//'; |
| 405 | 449 | if ( isset( $parts['user'] ) ) |
| 406 | 450 | { |
| 407 | 451 | $url .= $parts['user']; |
| 408 | - if ( isset( $parts['pass'] ) ) |
|
| 409 | - $url .= ':' . $parts['pass']; |
|
| 452 | + if ( isset( $parts['pass'] ) ) { |
|
| 453 | + $url .= ':' . $parts['pass']; |
|
| 454 | + } |
|
| 410 | 455 | $url .= '@'; |
| 411 | 456 | } |
| 412 | - if ( preg_match( '!^[\da-f]*:[\da-f.:]+$!ui', $parts['host'] ) ) |
|
| 413 | - $url .= '[' . $parts['host'] . ']'; // IPv6 |
|
| 414 | - else |
|
| 415 | - $url .= $parts['host']; // IPv4 or name |
|
| 416 | - if ( isset( $parts['port'] ) ) |
|
| 417 | - $url .= ':' . $parts['port']; |
|
| 418 | - if ( !empty( $parts['path'] ) && $parts['path'][0] != '/' ) |
|
| 419 | - $url .= '/'; |
|
| 420 | - } |
|
| 421 | - if ( !empty( $parts['path'] ) ) |
|
| 422 | - $url .= $parts['path']; |
|
| 423 | - if ( isset( $parts['query'] ) ) |
|
| 424 | - $url .= '?' . $parts['query']; |
|
| 425 | - if ( isset( $parts['fragment'] ) ) |
|
| 426 | - $url .= '#' . $parts['fragment']; |
|
| 457 | + if ( preg_match( '!^[\da-f]*:[\da-f.:]+$!ui', $parts['host'] ) ) { |
|
| 458 | + $url .= '[' . $parts['host'] . ']'; |
|
| 459 | + } |
|
| 460 | + // IPv6 |
|
| 461 | + else { |
|
| 462 | + $url .= $parts['host']; |
|
| 463 | + } |
|
| 464 | + // IPv4 or name |
|
| 465 | + if ( isset( $parts['port'] ) ) { |
|
| 466 | + $url .= ':' . $parts['port']; |
|
| 467 | + } |
|
| 468 | + if ( !empty( $parts['path'] ) && $parts['path'][0] != '/' ) { |
|
| 469 | + $url .= '/'; |
|
| 470 | + } |
|
| 471 | + } |
|
| 472 | + if ( !empty( $parts['path'] ) ) { |
|
| 473 | + $url .= $parts['path']; |
|
| 474 | + } |
|
| 475 | + if ( isset( $parts['query'] ) ) { |
|
| 476 | + $url .= '?' . $parts['query']; |
|
| 477 | + } |
|
| 478 | + if ( isset( $parts['fragment'] ) ) { |
|
| 479 | + $url .= '#' . $parts['fragment']; |
|
| 480 | + } |
|
| 427 | 481 | return $url; |
| 428 | 482 | } |
| 429 | 483 | |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | public static function isSame(string $to, string $from) |
| 37 | 37 | { |
| 38 | - return (self::toDatabase($to)===self::toDatabase($from)); |
|
| 38 | + return (self::toDatabase($to) === self::toDatabase($from)); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | |
@@ -46,8 +46,8 @@ discard block |
||
| 46 | 46 | * @return string Directory |
| 47 | 47 | */ |
| 48 | 48 | public function parseDir($url) { |
| 49 | - $slash = strrpos($url,'/'); |
|
| 50 | - return substr($url,0,$slash+1); |
|
| 49 | + $slash = strrpos($url, '/'); |
|
| 50 | + return substr($url, 0, $slash+1); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
@@ -70,15 +70,15 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | $relativeUrl = self::urlToAbsolute($baseUrl, $relativeUrl); //make them absolute, not relative |
| 72 | 72 | |
| 73 | - if (stripos($relativeUrl,'#') != FALSE) { |
|
| 74 | - $relativeUrl = substr($relativeUrl,0,stripos($relativeUrl,'#')); //remove anchors |
|
| 73 | + if (stripos($relativeUrl, '#') != FALSE) { |
|
| 74 | + $relativeUrl = substr($relativeUrl, 0, stripos($relativeUrl, '#')); //remove anchors |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - if (!preg_match('#(^http://(.*)/$)|http://(.*)/(.*)\.([A-Za-z0-9]+)|http://(.*)/([^\?\#]*)(\?|\#)([^/]*)#i',$relativeUrl)) { |
|
| 77 | + if (!preg_match('#(^http://(.*)/$)|http://(.*)/(.*)\.([A-Za-z0-9]+)|http://(.*)/([^\?\#]*)(\?|\#)([^/]*)#i', $relativeUrl)) { |
|
| 78 | 78 | $relativeUrl .= '/'; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - $relativeUrl = preg_replace('#http://([^.]+).([a-zA-z]{3})/#i','http://www.$1.$2/',$relativeUrl); |
|
| 81 | + $relativeUrl = preg_replace('#http://([^.]+).([a-zA-z]{3})/#i', 'http://www.$1.$2/', $relativeUrl); |
|
| 82 | 82 | return $relativeUrl; |
| 83 | 83 | } |
| 84 | 84 | |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * @return bool true on image, false on anything else |
| 91 | 91 | */ |
| 92 | 92 | public static function isImage($link) { |
| 93 | - if (preg_match('%\.(gif|jpe?g|png|bmp)$%i',$link)) return true; |
|
| 93 | + if (preg_match('%\.(gif|jpe?g|png|bmp)$%i', $link)) return true; |
|
| 94 | 94 | else return false; |
| 95 | 95 | } |
| 96 | 96 | |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | foreach ($excludedArray as $pattern) { |
| 136 | - if ( preg_match($pattern, urldecode($link)) ) { |
|
| 136 | + if (preg_match($pattern, urldecode($link))) { |
|
| 137 | 137 | echo "<p>matched exclude pattern <b>$pattern</b> in ".urldecode($link)."</p>"; |
| 138 | 138 | return TRUE; |
| 139 | 139 | } |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | * @return bool true on mailto:, false on everything else |
| 149 | 149 | */ |
| 150 | 150 | public static function isMailto($link) { |
| 151 | - if (stripos($link,'mailto:')===FALSE) return false; |
|
| 151 | + if (stripos($link, 'mailto:') === FALSE) return false; |
|
| 152 | 152 | else return true; |
| 153 | 153 | } |
| 154 | 154 | |
@@ -175,73 +175,73 @@ discard block |
||
| 175 | 175 | * @params string $relativeURL URL to convert to absolute |
| 176 | 176 | * @return string Absolute URL |
| 177 | 177 | */ |
| 178 | - public static function urlToAbsolute( $baseUrl, $relativeUrl ) { |
|
| 178 | + public static function urlToAbsolute($baseUrl, $relativeUrl) { |
|
| 179 | 179 | // If relative URL has a scheme, clean path and return. |
| 180 | - $r = self::splitUrl( $relativeUrl ); |
|
| 181 | - if ( $r === FALSE ) { |
|
| 180 | + $r = self::splitUrl($relativeUrl); |
|
| 181 | + if ($r === FALSE) { |
|
| 182 | 182 | return FALSE; |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | |
| 186 | - if ( !empty( $r['scheme'] ) ) |
|
| 186 | + if (!empty($r['scheme'])) |
|
| 187 | 187 | { |
| 188 | - if ( !empty( $r['path'] ) && $r['path'][0] == '/' ) { |
|
| 189 | - $r['path'] = self::urlRemoveDotSegments( $r['path'] ); |
|
| 188 | + if (!empty($r['path']) && $r['path'][0] == '/') { |
|
| 189 | + $r['path'] = self::urlRemoveDotSegments($r['path']); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - return self::joinUrl( $r ); |
|
| 192 | + return self::joinUrl($r); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | // Make sure the base URL is absolute. |
| 196 | - $b = self::splitUrl( $baseUrl ); |
|
| 197 | - if ( $b === FALSE || empty( $b['scheme'] ) || empty( $b['host'] ) ) { |
|
| 196 | + $b = self::splitUrl($baseUrl); |
|
| 197 | + if ($b === FALSE || empty($b['scheme']) || empty($b['host'])) { |
|
| 198 | 198 | return FALSE; |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | $r['scheme'] = $b['scheme']; |
| 202 | 202 | |
| 203 | 203 | // If relative URL has an authority, clean path and return. |
| 204 | - if ( isset( $r['host'] ) ) |
|
| 204 | + if (isset($r['host'])) |
|
| 205 | 205 | { |
| 206 | - if ( !empty( $r['path'] ) ) { |
|
| 207 | - $r['path'] = self::urlRemoveDotSegments( $r['path'] ); |
|
| 206 | + if (!empty($r['path'])) { |
|
| 207 | + $r['path'] = self::urlRemoveDotSegments($r['path']); |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - return self::joinUrl( $r ); |
|
| 210 | + return self::joinUrl($r); |
|
| 211 | 211 | } |
| 212 | - unset( $r['port'] ); |
|
| 213 | - unset( $r['user'] ); |
|
| 214 | - unset( $r['pass'] ); |
|
| 212 | + unset($r['port']); |
|
| 213 | + unset($r['user']); |
|
| 214 | + unset($r['pass']); |
|
| 215 | 215 | |
| 216 | 216 | // Copy base authority. |
| 217 | 217 | $r['host'] = $b['host']; |
| 218 | - if ( isset( $b['port'] ) ) $r['port'] = $b['port']; |
|
| 219 | - if ( isset( $b['user'] ) ) $r['user'] = $b['user']; |
|
| 220 | - if ( isset( $b['pass'] ) ) $r['pass'] = $b['pass']; |
|
| 218 | + if (isset($b['port'])) $r['port'] = $b['port']; |
|
| 219 | + if (isset($b['user'])) $r['user'] = $b['user']; |
|
| 220 | + if (isset($b['pass'])) $r['pass'] = $b['pass']; |
|
| 221 | 221 | |
| 222 | 222 | // If relative URL has no path, use base path |
| 223 | - if ( empty( $r['path'] ) ) |
|
| 223 | + if (empty($r['path'])) |
|
| 224 | 224 | { |
| 225 | - if ( !empty( $b['path'] ) ) { |
|
| 225 | + if (!empty($b['path'])) { |
|
| 226 | 226 | $r['path'] = $b['path']; |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - if ( !isset( $r['query'] ) && isset( $b['query'] ) ) { |
|
| 229 | + if (!isset($r['query']) && isset($b['query'])) { |
|
| 230 | 230 | $r['query'] = $b['query']; |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | - return self::joinUrl( $r ); |
|
| 233 | + return self::joinUrl($r); |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | // If relative URL path doesn't start with /, merge with base path |
| 237 | - if ( $r['path'][0] != '/' ) |
|
| 237 | + if ($r['path'][0] != '/') |
|
| 238 | 238 | { |
| 239 | - $base = mb_strrchr( $b['path'], '/', TRUE, 'UTF-8' ); |
|
| 240 | - if ( $base === FALSE ) $base = ''; |
|
| 241 | - $r['path'] = $base . '/' . $r['path']; |
|
| 239 | + $base = mb_strrchr($b['path'], '/', TRUE, 'UTF-8'); |
|
| 240 | + if ($base === FALSE) $base = ''; |
|
| 241 | + $r['path'] = $base.'/'.$r['path']; |
|
| 242 | 242 | } |
| 243 | - $r['path'] = self::urlRemoveDotSegments( $r['path'] ); |
|
| 244 | - return self::joinUrl( $r ); |
|
| 243 | + $r['path'] = self::urlRemoveDotSegments($r['path']); |
|
| 244 | + return self::joinUrl($r); |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | /** |
@@ -251,29 +251,29 @@ discard block |
||
| 251 | 251 | * Code distributed under OSI BSD (http://www.opensource.org/licenses/bsd-license.php) |
| 252 | 252 | * |
| 253 | 253 | */ |
| 254 | - public static function urlRemoveDotSegments( $path ) { |
|
| 254 | + public static function urlRemoveDotSegments($path) { |
|
| 255 | 255 | // multi-byte character explode |
| 256 | - $inSegs = preg_split( '!/!u', $path ); |
|
| 256 | + $inSegs = preg_split('!/!u', $path); |
|
| 257 | 257 | $outSegs = array( ); |
| 258 | - foreach ( $inSegs as $seg ) |
|
| 258 | + foreach ($inSegs as $seg) |
|
| 259 | 259 | { |
| 260 | - if ( $seg == '' || $seg == '.') { |
|
| 260 | + if ($seg == '' || $seg == '.') { |
|
| 261 | 261 | continue; |
| 262 | 262 | } |
| 263 | - if ( $seg == '..' ) { |
|
| 264 | - array_pop( $outSegs ); |
|
| 263 | + if ($seg == '..') { |
|
| 264 | + array_pop($outSegs); |
|
| 265 | 265 | } else { |
| 266 | - array_push( $outSegs, $seg ); |
|
| 266 | + array_push($outSegs, $seg); |
|
| 267 | 267 | } |
| 268 | 268 | } |
| 269 | - $outPath = implode( '/', $outSegs ); |
|
| 270 | - if ( $path[0] == '/' ) { |
|
| 271 | - $outPath = '/' . $outPath; |
|
| 269 | + $outPath = implode('/', $outSegs); |
|
| 270 | + if ($path[0] == '/') { |
|
| 271 | + $outPath = '/'.$outPath; |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | // compare last multi-byte character against '/' |
| 275 | - if ( $outPath != '/' && |
|
| 276 | - (mb_strlen($path)-1) == mb_strrpos( $path, '/', 'UTF-8' ) ) { |
|
| 275 | + if ($outPath != '/' && |
|
| 276 | + (mb_strlen($path)-1) == mb_strrpos($path, '/', 'UTF-8')) { |
|
| 277 | 277 | $outPath .= '/'; |
| 278 | 278 | } |
| 279 | 279 | |
@@ -287,16 +287,16 @@ discard block |
||
| 287 | 287 | * Code distributed under OSI BSD (http://www.opensource.org/licenses/bsd-license.php) |
| 288 | 288 | * |
| 289 | 289 | */ |
| 290 | - public static function splitUrl( $url, $decode=TRUE ) |
|
| 290 | + public static function splitUrl($url, $decode = TRUE) |
|
| 291 | 291 | { |
| 292 | 292 | $m = []; |
| 293 | 293 | $xunressub = 'a-zA-Z\d\-._~\!$&\'()*+,;='; |
| 294 | - $xpchar = $xunressub . ':@%'; |
|
| 294 | + $xpchar = $xunressub.':@%'; |
|
| 295 | 295 | |
| 296 | 296 | $xscheme = '([a-zA-Z][a-zA-Z\d+-.]*)'; |
| 297 | 297 | |
| 298 | - $xuserinfo = '(([' . $xunressub . '%]*)' . |
|
| 299 | - '(:([' . $xunressub . ':%]*))?)'; |
|
| 298 | + $xuserinfo = '((['.$xunressub.'%]*)'. |
|
| 299 | + '(:(['.$xunressub.':%]*))?)'; |
|
| 300 | 300 | |
| 301 | 301 | $xipv4 = '(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})'; |
| 302 | 302 | |
@@ -305,64 +305,64 @@ discard block |
||
| 305 | 305 | $xhost_name = '([a-zA-Z%]+)'; |
| 306 | 306 | // $xhost_name = '([a-zA-Z\d-.%]+)'; @todo alterado pq tava dando erro nesse parser |
| 307 | 307 | |
| 308 | - $xhost = '(' . $xhost_name . '|' . $xipv4 . '|' . $xipv6 . ')'; |
|
| 308 | + $xhost = '('.$xhost_name.'|'.$xipv4.'|'.$xipv6.')'; |
|
| 309 | 309 | $xport = '(\d*)'; |
| 310 | - $xauthority = '((' . $xuserinfo . '@)?' . $xhost . |
|
| 311 | - '?(:' . $xport . ')?)'; |
|
| 310 | + $xauthority = '(('.$xuserinfo.'@)?'.$xhost. |
|
| 311 | + '?(:'.$xport.')?)'; |
|
| 312 | 312 | |
| 313 | - $xslash_seg = '(/[' . $xpchar . ']*)'; |
|
| 314 | - $xpath_authabs = '((//' . $xauthority . ')((/[' . $xpchar . ']*)*))'; |
|
| 315 | - $xpath_rel = '([' . $xpchar . ']+' . $xslash_seg . '*)'; |
|
| 316 | - $xpath_abs = '(/(' . $xpath_rel . ')?)'; |
|
| 317 | - $xapath = '(' . $xpath_authabs . '|' . $xpath_abs . |
|
| 318 | - '|' . $xpath_rel . ')'; |
|
| 313 | + $xslash_seg = '(/['.$xpchar.']*)'; |
|
| 314 | + $xpath_authabs = '((//'.$xauthority.')((/['.$xpchar.']*)*))'; |
|
| 315 | + $xpath_rel = '(['.$xpchar.']+'.$xslash_seg.'*)'; |
|
| 316 | + $xpath_abs = '(/('.$xpath_rel.')?)'; |
|
| 317 | + $xapath = '('.$xpath_authabs.'|'.$xpath_abs. |
|
| 318 | + '|'.$xpath_rel.')'; |
|
| 319 | 319 | |
| 320 | - $xqueryfrag = '([' . $xpchar . '/?' . ']*)'; |
|
| 320 | + $xqueryfrag = '(['.$xpchar.'/?'.']*)'; |
|
| 321 | 321 | |
| 322 | - $xurl = '^(' . $xscheme . ':)?' . $xapath . '?' . |
|
| 323 | - '(\?' . $xqueryfrag . ')?(#' . $xqueryfrag . ')?$'; |
|
| 322 | + $xurl = '^('.$xscheme.':)?'.$xapath.'?'. |
|
| 323 | + '(\?'.$xqueryfrag.')?(#'.$xqueryfrag.')?$'; |
|
| 324 | 324 | |
| 325 | 325 | |
| 326 | 326 | // Split the URL into components. |
| 327 | - if ( !preg_match( '!' . $xurl . '!', $url, $m ) ) { |
|
| 327 | + if (!preg_match('!'.$xurl.'!', $url, $m)) { |
|
| 328 | 328 | return FALSE; |
| 329 | 329 | } |
| 330 | 330 | |
| 331 | - if ( !empty($m[2]) ) $parts['scheme'] = strtolower($m[2]); |
|
| 331 | + if (!empty($m[2])) $parts['scheme'] = strtolower($m[2]); |
|
| 332 | 332 | |
| 333 | - if ( !empty($m[7]) ) { |
|
| 334 | - if ( isset( $m[9] ) ) $parts['user'] = $m[9]; |
|
| 335 | - else $parts['user'] = ''; |
|
| 333 | + if (!empty($m[7])) { |
|
| 334 | + if (isset($m[9])) $parts['user'] = $m[9]; |
|
| 335 | + else $parts['user'] = ''; |
|
| 336 | 336 | } |
| 337 | - if ( !empty($m[10]) ) $parts['pass'] = $m[11]; |
|
| 337 | + if (!empty($m[10])) $parts['pass'] = $m[11]; |
|
| 338 | 338 | |
| 339 | - if ( !empty($m[13]) ) $h=$parts['host'] = $m[13]; |
|
| 340 | - else if ( !empty($m[14]) ) $parts['host'] = $m[14]; |
|
| 341 | - else if ( !empty($m[16]) ) $parts['host'] = $m[16]; |
|
| 342 | - else if ( !empty( $m[5] ) ) $parts['host'] = ''; |
|
| 343 | - if ( !empty($m[17]) ) $parts['port'] = $m[18]; |
|
| 339 | + if (!empty($m[13])) $h = $parts['host'] = $m[13]; |
|
| 340 | + else if (!empty($m[14])) $parts['host'] = $m[14]; |
|
| 341 | + else if (!empty($m[16])) $parts['host'] = $m[16]; |
|
| 342 | + else if (!empty($m[5])) $parts['host'] = ''; |
|
| 343 | + if (!empty($m[17])) $parts['port'] = $m[18]; |
|
| 344 | 344 | |
| 345 | - if ( !empty($m[19]) ) $parts['path'] = $m[19]; |
|
| 346 | - else if ( !empty($m[21]) ) $parts['path'] = $m[21]; |
|
| 347 | - else if ( !empty($m[25]) ) $parts['path'] = $m[25]; |
|
| 345 | + if (!empty($m[19])) $parts['path'] = $m[19]; |
|
| 346 | + else if (!empty($m[21])) $parts['path'] = $m[21]; |
|
| 347 | + else if (!empty($m[25])) $parts['path'] = $m[25]; |
|
| 348 | 348 | |
| 349 | - if ( !empty($m[27]) ) $parts['query'] = $m[28]; |
|
| 350 | - if ( !empty($m[29]) ) $parts['fragment']= $m[30]; |
|
| 349 | + if (!empty($m[27])) $parts['query'] = $m[28]; |
|
| 350 | + if (!empty($m[29])) $parts['fragment'] = $m[30]; |
|
| 351 | 351 | |
| 352 | - if ( !$decode ) |
|
| 352 | + if (!$decode) |
|
| 353 | 353 | return $parts; |
| 354 | - if ( !empty($parts['user']) ) |
|
| 355 | - $parts['user'] = rawurldecode( $parts['user'] ); |
|
| 356 | - if ( !empty($parts['pass']) ) |
|
| 357 | - $parts['pass'] = rawurldecode( $parts['pass'] ); |
|
| 358 | - if ( !empty($parts['path']) ) |
|
| 359 | - $parts['path'] = rawurldecode( $parts['path'] ); |
|
| 360 | - if ( isset($h) ) |
|
| 361 | - $parts['host'] = rawurldecode( $parts['host'] ); |
|
| 362 | - if ( !empty($parts['query']) ) |
|
| 363 | - $parts['query'] = rawurldecode( $parts['query'] ); |
|
| 364 | - if ( !empty($parts['fragment']) ) |
|
| 365 | - $parts['fragment'] = rawurldecode( $parts['fragment'] ); |
|
| 354 | + if (!empty($parts['user'])) |
|
| 355 | + $parts['user'] = rawurldecode($parts['user']); |
|
| 356 | + if (!empty($parts['pass'])) |
|
| 357 | + $parts['pass'] = rawurldecode($parts['pass']); |
|
| 358 | + if (!empty($parts['path'])) |
|
| 359 | + $parts['path'] = rawurldecode($parts['path']); |
|
| 360 | + if (isset($h)) |
|
| 361 | + $parts['host'] = rawurldecode($parts['host']); |
|
| 362 | + if (!empty($parts['query'])) |
|
| 363 | + $parts['query'] = rawurldecode($parts['query']); |
|
| 364 | + if (!empty($parts['fragment'])) |
|
| 365 | + $parts['fragment'] = rawurldecode($parts['fragment']); |
|
| 366 | 366 | return $parts; |
| 367 | 367 | } |
| 368 | 368 | |
@@ -373,62 +373,62 @@ discard block |
||
| 373 | 373 | * Code distributed under OSI BSD (http://www.opensource.org/licenses/bsd-license.php) |
| 374 | 374 | * |
| 375 | 375 | */ |
| 376 | - public static function joinUrl( $parts, $encode=TRUE ) |
|
| 376 | + public static function joinUrl($parts, $encode = TRUE) |
|
| 377 | 377 | { |
| 378 | - if ( $encode ) |
|
| 378 | + if ($encode) |
|
| 379 | 379 | { |
| 380 | - if ( isset( $parts['user'] ) ) { |
|
| 381 | - $parts['user'] = rawurlencode( $parts['user'] ); |
|
| 380 | + if (isset($parts['user'])) { |
|
| 381 | + $parts['user'] = rawurlencode($parts['user']); |
|
| 382 | 382 | } |
| 383 | - if ( isset( $parts['pass'] ) ) { |
|
| 384 | - $parts['pass'] = rawurlencode( $parts['pass'] ); |
|
| 383 | + if (isset($parts['pass'])) { |
|
| 384 | + $parts['pass'] = rawurlencode($parts['pass']); |
|
| 385 | 385 | } |
| 386 | - if ( isset( $parts['host'] ) && |
|
| 387 | - !preg_match( '!^(\[[\da-f.:]+\]])|([\da-f.:]+)$!ui', $parts['host'] ) ) { |
|
| 388 | - $parts['host'] = rawurlencode( $parts['host'] ); |
|
| 386 | + if (isset($parts['host']) && |
|
| 387 | + !preg_match('!^(\[[\da-f.:]+\]])|([\da-f.:]+)$!ui', $parts['host'])) { |
|
| 388 | + $parts['host'] = rawurlencode($parts['host']); |
|
| 389 | 389 | } |
| 390 | - if ( !empty( $parts['path'] ) ) { |
|
| 391 | - $parts['path'] = preg_replace( '!%2F!ui', '/', |
|
| 392 | - rawurlencode( $parts['path'] ) ); |
|
| 390 | + if (!empty($parts['path'])) { |
|
| 391 | + $parts['path'] = preg_replace('!%2F!ui', '/', |
|
| 392 | + rawurlencode($parts['path'])); |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | - if ( isset( $parts['query'] ) ) { |
|
| 396 | - $parts['query'] = rawurlencode( $parts['query'] ); |
|
| 395 | + if (isset($parts['query'])) { |
|
| 396 | + $parts['query'] = rawurlencode($parts['query']); |
|
| 397 | 397 | } |
| 398 | 398 | |
| 399 | - if ( isset( $parts['fragment'] ) ) { |
|
| 400 | - $parts['fragment'] = rawurlencode( $parts['fragment'] ); |
|
| 399 | + if (isset($parts['fragment'])) { |
|
| 400 | + $parts['fragment'] = rawurlencode($parts['fragment']); |
|
| 401 | 401 | } |
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | $url = ''; |
| 405 | - if ( !empty( $parts['scheme'] ) ) |
|
| 406 | - $url .= $parts['scheme'] . ':'; |
|
| 407 | - if ( isset( $parts['host'] ) ) |
|
| 405 | + if (!empty($parts['scheme'])) |
|
| 406 | + $url .= $parts['scheme'].':'; |
|
| 407 | + if (isset($parts['host'])) |
|
| 408 | 408 | { |
| 409 | 409 | $url .= '//'; |
| 410 | - if ( isset( $parts['user'] ) ) |
|
| 410 | + if (isset($parts['user'])) |
|
| 411 | 411 | { |
| 412 | 412 | $url .= $parts['user']; |
| 413 | - if ( isset( $parts['pass'] ) ) |
|
| 414 | - $url .= ':' . $parts['pass']; |
|
| 413 | + if (isset($parts['pass'])) |
|
| 414 | + $url .= ':'.$parts['pass']; |
|
| 415 | 415 | $url .= '@'; |
| 416 | 416 | } |
| 417 | - if ( preg_match( '!^[\da-f]*:[\da-f.:]+$!ui', $parts['host'] ) ) |
|
| 418 | - $url .= '[' . $parts['host'] . ']'; // IPv6 |
|
| 417 | + if (preg_match('!^[\da-f]*:[\da-f.:]+$!ui', $parts['host'])) |
|
| 418 | + $url .= '['.$parts['host'].']'; // IPv6 |
|
| 419 | 419 | else |
| 420 | - $url .= $parts['host']; // IPv4 or name |
|
| 421 | - if ( isset( $parts['port'] ) ) |
|
| 422 | - $url .= ':' . $parts['port']; |
|
| 423 | - if ( !empty( $parts['path'] ) && $parts['path'][0] != '/' ) |
|
| 420 | + $url .= $parts['host']; // IPv4 or name |
|
| 421 | + if (isset($parts['port'])) |
|
| 422 | + $url .= ':'.$parts['port']; |
|
| 423 | + if (!empty($parts['path']) && $parts['path'][0] != '/') |
|
| 424 | 424 | $url .= '/'; |
| 425 | 425 | } |
| 426 | - if ( !empty( $parts['path'] ) ) |
|
| 426 | + if (!empty($parts['path'])) |
|
| 427 | 427 | $url .= $parts['path']; |
| 428 | - if ( isset( $parts['query'] ) ) |
|
| 429 | - $url .= '?' . $parts['query']; |
|
| 430 | - if ( isset( $parts['fragment'] ) ) |
|
| 431 | - $url .= '#' . $parts['fragment']; |
|
| 428 | + if (isset($parts['query'])) |
|
| 429 | + $url .= '?'.$parts['query']; |
|
| 430 | + if (isset($parts['fragment'])) |
|
| 431 | + $url .= '#'.$parts['fragment']; |
|
| 432 | 432 | return $url; |
| 433 | 433 | } |
| 434 | 434 | |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | |
| 95 | 95 | public static function isSame(string $to, string $from) |
| 96 | 96 | { |
| 97 | - return (self::toDatabase($to)===self::toDatabase($from)); |
|
| 97 | + return (self::toDatabase($to) === self::toDatabase($from)); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | public static function validate($email) |
| 106 | 106 | { |
| 107 | - if ((boolean) filter_var($email, FILTER_VALIDATE_EMAIL)===false){ |
|
| 107 | + if ((boolean) filter_var($email, FILTER_VALIDATE_EMAIL) === false) { |
|
| 108 | 108 | return false; |
| 109 | 109 | } |
| 110 | 110 | |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | */ |
| 159 | 159 | public function setEmailFrom($email) { |
| 160 | 160 | if (!self::validate($email)) { |
| 161 | - $this->set_error('Invalid address : ' . $email); |
|
| 161 | + $this->set_error('Invalid address : '.$email); |
|
| 162 | 162 | $this->edebug($this->ErrorInfo); |
| 163 | 163 | if ($this->exceptions) { |
| 164 | 164 | throw new Exception($this->ErrorInfo); |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | * @param int $seconds |
| 173 | 173 | */ |
| 174 | 174 | public function setConnectionTimeout($seconds) { |
| 175 | - if ($seconds > 0) { |
|
| 175 | + if ($seconds>0) { |
|
| 176 | 176 | $this->max_connection_timeout = (int) $seconds; |
| 177 | 177 | } |
| 178 | 178 | } |
@@ -182,13 +182,13 @@ discard block |
||
| 182 | 182 | * @param int $seconds |
| 183 | 183 | */ |
| 184 | 184 | public function setStreamTimeout($seconds) { |
| 185 | - if ($seconds > 0) { |
|
| 185 | + if ($seconds>0) { |
|
| 186 | 186 | $this->stream_timeout = (int) $seconds; |
| 187 | 187 | } |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | public function setStreamTimeoutWait($seconds) { |
| 191 | - if ($seconds >= 0) { |
|
| 191 | + if ($seconds>=0) { |
|
| 192 | 192 | $this->stream_timeout_wait = (int) $seconds; |
| 193 | 193 | } |
| 194 | 194 | } |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | * @return boolean True if an error did occur. |
| 248 | 248 | */ |
| 249 | 249 | public function isError() { |
| 250 | - return ($this->error_count > 0); |
|
| 250 | + return ($this->error_count>0); |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | /** |
@@ -277,9 +277,9 @@ discard block |
||
| 277 | 277 | default: |
| 278 | 278 | //Normalize line breaks |
| 279 | 279 | $str = preg_replace('/(\r\n|\r|\n)/ms', "\n", $str); |
| 280 | - echo gmdate('Y-m-d H:i:s') . "\t" . str_replace( |
|
| 280 | + echo gmdate('Y-m-d H:i:s')."\t".str_replace( |
|
| 281 | 281 | "\n", "\n \t ", trim($str) |
| 282 | - ) . "\n"; |
|
| 282 | + )."\n"; |
|
| 283 | 283 | } |
| 284 | 284 | } |
| 285 | 285 | |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | * suppress error output from stream socket client... |
| 310 | 310 | * Thanks Michael. |
| 311 | 311 | */ |
| 312 | - $this->stream = @stream_socket_client("tcp://" . $host . ":" . $this->port, $errno, $errstr, $timeout); |
|
| 312 | + $this->stream = @stream_socket_client("tcp://".$host.":".$this->port, $errno, $errstr, $timeout); |
|
| 313 | 313 | if ($this->stream === FALSE) { |
| 314 | 314 | if ($errno == 0) { |
| 315 | 315 | $this->set_error("Problem initializing the socket"); |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | } |
| 320 | 320 | return FALSE; |
| 321 | 321 | } else { |
| 322 | - $this->edebug($host . ":" . $errstr); |
|
| 322 | + $this->edebug($host.":".$errstr); |
|
| 323 | 323 | } |
| 324 | 324 | } else { |
| 325 | 325 | stream_set_timeout($this->stream, $this->stream_timeout); |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | return FALSE; |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | - $this->_streamQuery("HELO " . self::parse_email($this->from)); |
|
| 347 | + $this->_streamQuery("HELO ".self::parse_email($this->from)); |
|
| 348 | 348 | $this->_streamResponse(); |
| 349 | 349 | $this->_streamQuery("MAIL FROM: <{$this->from}>"); |
| 350 | 350 | $this->_streamResponse(); |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | $this->_streamQuery("QUIT"); |
| 358 | 358 | fclose($this->stream); |
| 359 | 359 | |
| 360 | - $code = !empty($code2)?$code2:$code; |
|
| 360 | + $code = !empty($code2) ? $code2 : $code; |
|
| 361 | 361 | switch ($code) { |
| 362 | 362 | case '250': |
| 363 | 363 | /** |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | */ |
| 397 | 397 | protected function _streamQuery($query) { |
| 398 | 398 | $this->edebug($query); |
| 399 | - return stream_socket_sendto($this->stream, $query . self::CRLF); |
|
| 399 | + return stream_socket_sendto($this->stream, $query.self::CRLF); |
|
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | /** |
@@ -413,12 +413,12 @@ discard block |
||
| 413 | 413 | $this->edebug("Timed out while waiting for data! (timeout {$this->stream_timeout} seconds)"); |
| 414 | 414 | } |
| 415 | 415 | |
| 416 | - if ($reply === FALSE && $status['timed_out'] && $timed < $this->stream_timeout_wait) { |
|
| 417 | - return $this->_streamResponse($timed + $this->stream_timeout); |
|
| 416 | + if ($reply === FALSE && $status['timed_out'] && $timed<$this->stream_timeout_wait) { |
|
| 417 | + return $this->_streamResponse($timed+$this->stream_timeout); |
|
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | |
| 421 | - if ($reply !== FALSE && $status['unread_bytes'] > 0) { |
|
| 421 | + if ($reply !== FALSE && $status['unread_bytes']>0) { |
|
| 422 | 422 | $reply .= stream_get_line($this->stream, $status['unread_bytes'], self::CRLF); |
| 423 | 423 | } |
| 424 | 424 | $this->edebug($reply); |
@@ -11,10 +11,10 @@ discard block |
||
| 11 | 11 | public static function toDatabase(string $phone) |
| 12 | 12 | { |
| 13 | 13 | $phone = preg_replace('/[^0-9]/', '', $phone); |
| 14 | - if (substr((string) $phone,0,2)=='55') { |
|
| 14 | + if (substr((string) $phone, 0, 2) == '55') { |
|
| 15 | 15 | return $phone; |
| 16 | 16 | } |
| 17 | - if (empty($phone) || $phone=='55') { |
|
| 17 | + if (empty($phone) || $phone == '55') { |
|
| 18 | 18 | return null; |
| 19 | 19 | } |
| 20 | 20 | if (strlen($phone)>11) { |
@@ -32,19 +32,19 @@ discard block |
||
| 32 | 32 | { |
| 33 | 33 | $phone = self::break($phoneNumber); |
| 34 | 34 | |
| 35 | - if ((int) $phone['country'] === 0 ) { |
|
| 35 | + if ((int) $phone['country'] === 0) { |
|
| 36 | 36 | return false; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - if ((int) $phone['region'] === 0 ) { |
|
| 39 | + if ((int) $phone['region'] === 0) { |
|
| 40 | 40 | return false; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - if ((int) $phone['number'] === 0 ) { |
|
| 43 | + if ((int) $phone['number'] === 0) { |
|
| 44 | 44 | return false; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - if (strlen(static::toDatabase($phoneNumber)) < 12 || strlen(static::toDatabase($phoneNumber)) > 13) { |
|
| 47 | + if (strlen(static::toDatabase($phoneNumber))<12 || strlen(static::toDatabase($phoneNumber))>13) { |
|
| 48 | 48 | return false; |
| 49 | 49 | } |
| 50 | 50 | |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | |
| 74 | 74 | public static function isSame(string $to, string $from) |
| 75 | 75 | { |
| 76 | - return (self::toDatabase($to)===self::toDatabase($from)); |
|
| 76 | + return (self::toDatabase($to) === self::toDatabase($from)); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | } |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | public static function toDatabase(string $number) |
| 15 | 15 | { |
| 16 | - if(strpos($number, ',') > 0) { |
|
| 16 | + if (strpos($number, ',')>0) { |
|
| 17 | 17 | $number = str_replace('.', '', $number); |
| 18 | 18 | $number = str_replace(',', '.', $number); |
| 19 | 19 | } |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | public static function isSame(string $to, string $from) |
| 34 | 34 | { |
| 35 | - return (self::toDatabase($to)===self::toDatabase($from)); |
|
| 35 | + return (self::toDatabase($to) === self::toDatabase($from)); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | } |
@@ -13,11 +13,11 @@ discard block |
||
| 13 | 13 | public static function toDatabase($dataOriginal) |
| 14 | 14 | { |
| 15 | 15 | $data = explode('/', $dataOriginal); |
| 16 | - if (isset($data[2])){ |
|
| 17 | - if($data[1]>12){ |
|
| 18 | - return $data[2] .'-'. $data[0] .'-'. $data[1]; |
|
| 16 | + if (isset($data[2])) { |
|
| 17 | + if ($data[1]>12) { |
|
| 18 | + return $data[2].'-'.$data[0].'-'.$data[1]; |
|
| 19 | 19 | } |
| 20 | - return $data[2] .'-'. $data[1] .'-'. $data[0]; |
|
| 20 | + return $data[2].'-'.$data[1].'-'.$data[0]; |
|
| 21 | 21 | } |
| 22 | 22 | return $dataOriginal; |
| 23 | 23 | } |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | if ($year>99) { |
| 64 | 64 | return $year; |
| 65 | 65 | } |
| 66 | - if ($year>50){ |
|
| 66 | + if ($year>50) { |
|
| 67 | 67 | return 1900+$year; |
| 68 | 68 | } |
| 69 | 69 | return 2000+$year; |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | public static function isSame(string $to, string $from) |
| 73 | 73 | { |
| 74 | - return (self::toDatabase($to)===self::toDatabase($from)); |
|
| 74 | + return (self::toDatabase($to) === self::toDatabase($from)); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | public static function toDatabase($gender) |
| 25 | 25 | { |
| 26 | - return substr(((string) self::filter(strtoupper(preg_replace('/[^A-z]/', '',$gender)))), 0, 1); |
|
| 26 | + return substr(((string) self::filter(strtoupper(preg_replace('/[^A-z]/', '', $gender)))), 0, 1); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | public static function filter($gender) { |
@@ -38,11 +38,11 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | public static function toUser($gender) |
| 40 | 40 | { |
| 41 | - if($gender == 'M') { |
|
| 41 | + if ($gender == 'M') { |
|
| 42 | 42 | return 'Masculino'; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - if($gender == 'F') { |
|
| 45 | + if ($gender == 'F') { |
|
| 46 | 46 | return 'Feminino'; |
| 47 | 47 | } |
| 48 | 48 | |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | public static function isSame(string $to, string $from) |
| 64 | 64 | { |
| 65 | - return (self::toDatabase($to)===self::toDatabase($from)); |
|
| 65 | + return (self::toDatabase($to) === self::toDatabase($from)); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | } |