@@ -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 | } |
@@ -28,7 +28,7 @@ |
||
28 | 28 | |
29 | 29 | public static function isSame(string $to, string $from) |
30 | 30 | { |
31 | - return (self::toDatabase($to)===self::toDatabase($from)); |
|
31 | + return (self::toDatabase($to) === self::toDatabase($from)); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | } |
@@ -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 | } |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | public static function validate($birthdate) |
17 | 17 | { |
18 | - if (!parent::validate($birthdate)){ |
|
18 | + if (!parent::validate($birthdate)) { |
|
19 | 19 | return false; |
20 | 20 | } |
21 | 21 | |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | public static function isSame(string $to, string $from) |
26 | 26 | { |
27 | - return (self::toDatabase($to)===self::toDatabase($from)); |
|
27 | + return (self::toDatabase($to) === self::toDatabase($from)); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | } |
@@ -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 |
@@ -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 | } |
@@ -32,7 +32,7 @@ |
||
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 | } |