Refactored code to comply with PSR-*

Signed-off-by: Gergely POLONKAI <polesz@w00d5t0ck.info>
This commit is contained in:
Gergely POLONKAI
2012-08-16 15:52:41 +02:00
parent de00a6ad21
commit fab08cad6f
69 changed files with 5253 additions and 4673 deletions

View File

@@ -4,30 +4,40 @@ namespace KekRozsak\FrontBundle\Extensions;
class Slugifier
{
/**
* Slugify string
*
* @param string $text
* @return string
*/
public function slugify($text)
{
$text = trim(preg_replace('~[^\\pL\d]+~u', '-', $text));
/**
* Slugify string
*
* @param string $text
* @return string
*/
public function slugify($text)
{
$text = preg_replace(
'~[^-\w]+~',
'',
str_replace(
array('"', "'", ':'),
'',
strtolower(
iconv(
'utf-8',
'us-ascii//TRANSLIT',
trim(
preg_replace(
'~[^\\pL\d]+~u',
'-',
$text
)
)
)
)
)
);
if (function_exists('iconv'))
{
$text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
}
if (empty($text)) {
$text = 'n-a';
}
$text = strtolower($text);
$text = preg_replace('~[^-\w]+~', '', $text);
if (empty($text))
{
$text = 'n-a';
}
return $text;
}
return $text;
}
}