Permalink
Browse files

Remvoving dependence on String class in Inflector::slug.

  • Loading branch information...
1 parent d72dad5 commit 7902f6838b86466d6e634df3d5dc18047f136b52 @jperras jperras committed Apr 10, 2009
Showing with 3 additions and 4 deletions.
  1. +3 −4 cake/libs/inflector.php
View
@@ -429,9 +429,8 @@ function variable($string) {
* @link http://book.cakephp.org/view/572/Class-methods
*/
function slug($string, $replacement = '_') {
- if (!class_exists('String')) {
- require LIBS . 'string.php';
- }
+ $quotedReplacement = preg_quote($replacement, '/');
+
$map = array(
'/à|á|å|â/' => 'a',
'/è|é|ê|ẽ|ë/' => 'e',
@@ -449,7 +448,7 @@ function slug($string, $replacement = '_') {
'/ß/' => 'ss',
'/[^\w\s]/' => ' ',
'/\\s+/' => $replacement,
- String::insert('/^[:replacement]+|[:replacement]+$/', array('replacement' => preg_quote($replacement, '/'))) => '',
+ sprintf('/^[%s]+|[%s]+$/', $quotedReplacement, $quotedReplacement) => '',
);
return preg_replace(array_keys($map), array_values($map), $string);
}

0 comments on commit 7902f68

Please sign in to comment.