AsciiSlugger
in package
implements
SluggerInterface, LocaleAwareInterface
Tags
Interfaces, Classes and Traits
- SluggerInterface
- Creates a URL-friendly slug from a given string.
- LocaleAwareInterface
Table of Contents
- LOCALE_TO_TRANSLITERATOR_ID = ['am' => 'Amharic-Latin', 'ar' => 'Arabic-Latin', 'az' => 'Azerbaijani-Latin', 'be' => 'Belarusian-Latin', 'bg' => 'Bulgarian-Latin', 'bn' => 'Bengali-Latin', 'de' => 'de-ASCII', 'el' => 'Greek-Latin', 'fa' => 'Persian-Latin', 'he' => 'Hebrew-Latin', 'hy' => 'Armenian-Latin', 'ka' => 'Georgian-Latin', 'kk' => 'Kazakh-Latin', 'ky' => 'Kirghiz-Latin', 'ko' => 'Korean-Latin', 'mk' => 'Macedonian-Latin', 'mn' => 'Mongolian-Latin', 'or' => 'Oriya-Latin', 'ps' => 'Pashto-Latin', 'ru' => 'Russian-Latin', 'sr' => 'Serbian-Latin', 'sr_Cyrl' => 'Serbian-Latin', 'th' => 'Thai-Latin', 'tk' => 'Turkmen-Latin', 'uk' => 'Ukrainian-Latin', 'uz' => 'Uzbek-Latin', 'zh' => 'Han-Latin']
- $defaultLocale : mixed
- $symbolsMap : mixed
- $transliterators : array<string|int, Transliterator>
- Cache of transliterators per locale.
- __construct() : mixed
- getLocale() : string
- Returns the current locale.
- setLocale() : mixed
- Sets the current locale.
- slug() : AbstractUnicodeString
- Creates a slug for the given string and locale, using appropriate transliteration when needed.
- createTransliterator() : Transliterator|null
- getParentLocale() : string|null
Constants
LOCALE_TO_TRANSLITERATOR_ID
private
mixed
LOCALE_TO_TRANSLITERATOR_ID
= ['am' => 'Amharic-Latin', 'ar' => 'Arabic-Latin', 'az' => 'Azerbaijani-Latin', 'be' => 'Belarusian-Latin', 'bg' => 'Bulgarian-Latin', 'bn' => 'Bengali-Latin', 'de' => 'de-ASCII', 'el' => 'Greek-Latin', 'fa' => 'Persian-Latin', 'he' => 'Hebrew-Latin', 'hy' => 'Armenian-Latin', 'ka' => 'Georgian-Latin', 'kk' => 'Kazakh-Latin', 'ky' => 'Kirghiz-Latin', 'ko' => 'Korean-Latin', 'mk' => 'Macedonian-Latin', 'mn' => 'Mongolian-Latin', 'or' => 'Oriya-Latin', 'ps' => 'Pashto-Latin', 'ru' => 'Russian-Latin', 'sr' => 'Serbian-Latin', 'sr_Cyrl' => 'Serbian-Latin', 'th' => 'Thai-Latin', 'tk' => 'Turkmen-Latin', 'uk' => 'Ukrainian-Latin', 'uz' => 'Uzbek-Latin', 'zh' => 'Han-Latin']
Properties
$defaultLocale
private
mixed
$defaultLocale
$symbolsMap
private
mixed
$symbolsMap
= ['en' => ['@' => 'at', '&' => 'and']]
$transliterators
Cache of transliterators per locale.
private
array<string|int, Transliterator>
$transliterators
= []
Methods
__construct()
public
__construct([string $defaultLocale = null ][, array<string|int, mixed>|Closure|null $symbolsMap = null ]) : mixed
Parameters
- $defaultLocale : string = null
- $symbolsMap : array<string|int, mixed>|Closure|null = null
Return values
mixed —getLocale()
Returns the current locale.
public
getLocale() : string
Return values
string —setLocale()
Sets the current locale.
public
setLocale(mixed $locale) : mixed
Parameters
- $locale : mixed
-
The locale
Return values
mixed —slug()
Creates a slug for the given string and locale, using appropriate transliteration when needed.
public
slug(string $string[, string $separator = '-' ][, string $locale = null ]) : AbstractUnicodeString
Parameters
- $string : string
- $separator : string = '-'
- $locale : string = null
Return values
AbstractUnicodeString —createTransliterator()
private
createTransliterator(string $locale) : Transliterator|null
Parameters
- $locale : string
Return values
Transliterator|null —getParentLocale()
private
static getParentLocale(string|null $locale) : string|null
Parameters
- $locale : string|null