@@ -126,19 +126,17 @@ public function addRegra($nome, $posicao) {
126
126
* @return int $id Retorna a Id que pode estar na URL
127
127
*/
128
128
public function getId ($ posicao = false ) {
129
- $ id = null ;
129
+ $ id = 0 ;
130
130
if ($ posicao === false ) {
131
131
$ last = (count ($ this ->partes ))-1 ;
132
132
$ aux = array_reverse (explode ("- " ,$ this ->partes [$ last ]));
133
- return (int ) $ aux [0 ];
133
+ $ id = (int ) $ aux [0 ];
134
134
} else {
135
- if (is_int ($ posicao ) and $ this ->get ($ posicao )!=="" ) {
136
- return array_reverse (explode ('- ' ,$ this ->get ($ posicao )))[0 ];
137
- }
138
- if (is_string ($ posicao ) and $ this ->get ($ posicao )!=="" ) {
139
- return array_reverse (explode ('- ' ,$ this ->get ($ posicao )))[0 ];
135
+ if ((is_int ($ posicao ) || is_string ($ posicao )) and $ this ->get ($ posicao )!=="" ) {
136
+ $ id = (int ) array_reverse (explode ('- ' ,$ this ->get ($ posicao )))[0 ];
140
137
}
141
138
}
139
+ return $ id ;
142
140
}
143
141
144
142
/**
@@ -156,6 +154,7 @@ public function getApos($palavra,$onlyKey = false) {
156
154
}
157
155
return ($ onlyKey ?(isset ($ this ->partes [$ wordKey +1 ])?$ wordKey +1 :"" ):(isset ($ this ->partes [$ wordKey +1 ])?$ this ->partes [$ wordKey +1 ]:"" ));
158
156
}
157
+ return false ;
159
158
}
160
159
161
160
/**
@@ -177,6 +176,7 @@ public function getURLApos($palavra) {
177
176
}
178
177
return implode ("/ " ,$ url );
179
178
}
179
+ return false ;
180
180
}
181
181
182
182
/**
@@ -202,6 +202,7 @@ public function getAntes($palavra,$onlyKey = false) {
202
202
}
203
203
return ($ onlyKey ?(isset ($ this ->partes [$ wordKey -1 ])?$ wordKey -1 :"" ):(isset ($ this ->partes [$ wordKey -1 ])?$ this ->partes [$ wordKey -1 ]:"" ));
204
204
}
205
+ return false ;
205
206
}
206
207
207
208
/**
@@ -229,6 +230,7 @@ public function getURLAntes($palavra) {
229
230
return false ;
230
231
}
231
232
}
233
+ return false ;
232
234
}
233
235
234
236
@@ -244,7 +246,7 @@ public function getIdAntes($palavra) {
244
246
* @param string $string Recebe um texto para converter em URL.
245
247
* @return string $novaUrl Esta função gera uma url para um link. Só deve ser usada para links diretos (sem "/")
246
248
*/
247
- public function tratar ($ string ) {
249
+ public function URLizer ($ string ) {
248
250
$ string = preg_replace ('/[áàãâä]/ui ' , 'a ' , $ string );
249
251
$ string = preg_replace ('/[éèêë]/ui ' , 'e ' , $ string );
250
252
$ string = preg_replace ('/[íìîï]/ui ' , 'i ' , $ string );
@@ -263,7 +265,7 @@ public function tratar($string) {
263
265
* @return string Retorna o Link gerado.
264
266
*/
265
267
public function gerarLink ($ texto , $ id = false ) {
266
- $ texto = $ this ->tratar ($ texto );
268
+ $ texto = $ this ->URLizer ($ texto );
267
269
if (strlen ($ texto ) > 50 ) {
268
270
$ texto = substr ($ texto , 0 , 50 );
269
271
}
0 commit comments