14
14
* 16/01/2021 -> getURLAntes (refatorado método)
15
15
* 16/01/2021 -> getIdAntes (refatorado método)
16
16
* 16/01/2021 -> Renomeado método gerarLinkWebsite para gerarLinkInterno
17
- *
17
+ * 20/01/2021 -> Melhorada performance geral da classe
18
18
*/
19
19
20
20
class url {
@@ -32,8 +32,7 @@ class url {
32
32
public function __construct ($ url = false , $ get = false ) {
33
33
$ this ->setGet ($ get );
34
34
$ 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 )!=="/ " ){
37
36
$ this ->url = $ this ->url ."/ " ;
38
37
}
39
38
$ this ->site = $ _SERVER ['HTTP_HOST ' ];
@@ -97,7 +96,7 @@ public function agora() {
97
96
* @return bool Verifica se possui o o que for informado aqui na url. Se tiver, retorna true.
98
97
*/
99
98
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 ))) {
101
100
return true ;
102
101
} else {
103
102
return false ;
@@ -152,7 +151,7 @@ public function getApos($palavra,$onlyKey = false) {
152
151
break ;
153
152
}
154
153
}
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 ));
156
155
}
157
156
return false ;
158
157
}
@@ -200,7 +199,7 @@ public function getAntes($palavra,$onlyKey = false) {
200
199
break ;
201
200
}
202
201
}
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 ));
204
203
}
205
204
return false ;
206
205
}
@@ -232,7 +231,6 @@ public function getURLAntes($palavra) {
232
231
}
233
232
return false ;
234
233
}
235
-
236
234
237
235
/**
238
236
* @param string $palavra Recebe a palavra para retornar a ID que há antes dela.
0 commit comments