Skip to content

Commit

Permalink
Allow $options arg for Text::slug() to be string for easy migration.
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Apr 2, 2016
1 parent 15fc48d commit cfd44eb
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/Utility/Text.php
Expand Up @@ -900,18 +900,25 @@ public static function transliterate($string, $transliteratorId = null)
* Returns a string with all spaces converted to dashes (by default),
* characters transliterated to ASCII characters, and non word characters removed.
*
* ### Options:
*
* - `replacement`: Replacement string. Default '-'.
* - `transliteratorId`: A valid tranliterator id string.
* If default `null` Text::$_defaultTransliteratorId to be used.
* If `false` no transliteration will be done, only non words will be removed.
* - `preserve`: Specific non-word character to preserve. Default `null`.
* For e.g. this option can be set to '.' to generate clean file names.
*
* @param string $string the string you want to slug
* @param array $options Valid options:
* - `replacement`: Replacement string. Default '-'.
* - `transliteratorId`: A valid tranliterator id string.
* If default `null` Text::$_defaultTransliteratorId to be used.
* If `false` no transliteration will be done, only non words will be removed.
* - `preserve`: Specific non-word character to preserve. Default `null`.
* For e.g. this option can be set to '.' to generate clean file names.
* @param array $options If string it will be use as replacement character
* or an array of options.
* @return string
*/
public static function slug($string, $options = [])
{
if (is_string($options)) {
$options = ['replacement' => $options];
}
$options += [
'replacement' => '-',
'transliteratorId' => null,
Expand Down

0 comments on commit cfd44eb

Please sign in to comment.