Skip to content

Commit 31929d7

Browse files
authored
Add files via upload
1 parent 82cc242 commit 31929d7

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

url.class.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* 16/01/2021 -> getURLAntes (refatorado método)
1515
* 16/01/2021 -> getIdAntes (refatorado método)
1616
* 16/01/2021 -> Renomeado método gerarLinkWebsite para gerarLinkInterno
17-
*
17+
* 20/01/2021 -> Melhorada performance geral da classe
1818
*/
1919

2020
class url {
@@ -32,8 +32,7 @@ class url {
3232
public function __construct($url = false, $get = false) {
3333
$this->setGet($get);
3434
$this->url = ($url ? $url : ($this->get ? preg_replace("/\?.*/", "", preg_replace("/http(s)?\:\/\//", "", $_SERVER['REQUEST_URI'])) : preg_replace("/http(s)?\:\/\//", "", $_SERVER['REQUEST_URI'])));
35-
$lastChar = substr($this->url, -1);
36-
if($lastChar!=="/"){
35+
if(substr($this->url, -1)!=="/"){
3736
$this->url = $this->url."/";
3837
}
3938
$this->site = $_SERVER['HTTP_HOST'];
@@ -97,7 +96,7 @@ public function agora() {
9796
* @return bool Verifica se possui o o que for informado aqui na url. Se tiver, retorna true.
9897
*/
9998
public function contem($palavra) {
100-
if ((in_array($palavra, $this->partes)) || ( in_array($this->tratar($palavra), $this->partes)) || preg_match("/$palavra/", implode('/',$this->partes))) {
99+
if ((in_array($palavra, $this->partes)) || ( in_array($this->tratar($palavra), $this->partes)) || $this->get($palavra)!=="" || preg_match("/$palavra/", implode('/',$this->partes))) {
101100
return true;
102101
} else {
103102
return false;
@@ -152,7 +151,7 @@ public function getApos($palavra,$onlyKey = false) {
152151
break;
153152
}
154153
}
155-
return ($onlyKey?(isset($this->partes[$wordKey+1])?$wordKey+1:""):(isset($this->partes[$wordKey+1])?$this->partes[$wordKey+1]:""));
154+
return ($onlyKey ? (isset($this->partes[$wordKey+1])?$wordKey+1 : false) : (isset($this->partes[$wordKey+1]) ? $this->partes[$wordKey+1] : false));
156155
}
157156
return false;
158157
}
@@ -200,7 +199,7 @@ public function getAntes($palavra,$onlyKey = false) {
200199
break;
201200
}
202201
}
203-
return ($onlyKey?(isset($this->partes[$wordKey-1])?$wordKey-1:""):(isset($this->partes[$wordKey-1])?$this->partes[$wordKey-1]:""));
202+
return ($onlyKey ? (isset($this->partes[$wordKey-1]) ? $wordKey-1 : false) : (isset($this->partes[$wordKey-1]) ? $this->partes[$wordKey-1] : false));
204203
}
205204
return false;
206205
}
@@ -232,7 +231,6 @@ public function getURLAntes($palavra) {
232231
}
233232
return false;
234233
}
235-
236234

237235
/**
238236
* @param string $palavra Recebe a palavra para retornar a ID que há antes dela.

0 commit comments

Comments
 (0)