Documentation

AsciiSlugger
in package
implements SluggerInterface, LocaleAwareInterface

Tags
author

Titouan Galopin galopintitouan@gmail.com

Table of Contents

Interfaces

SluggerInterface
Creates a URL-friendly slug from a given string.
LocaleAwareInterface

Constants

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  : string|null
$emoji  : bool|string
$symbolsMap  : Closure|array<string|int, mixed>
$transliterators  : array<string|int, Transliterator>
Cache of transliterators per locale.

Methods

__construct()  : mixed
getLocale()  : string
setLocale()  : void
slug()  : AbstractUnicodeString
Creates a slug for the given string and locale, using appropriate transliteration when needed.
withEmoji()  : static
createEmojiTransliterator()  : EmojiTransliterator|null
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

$symbolsMap

private Closure|array<string|int, mixed> $symbolsMap = ['en' => ['@' => 'at', '&' => 'and']]

$transliterators

Cache of transliterators per locale.

private array<string|int, Transliterator> $transliterators = []

Methods

__construct()

public __construct([string|null $defaultLocale = null ][, array<string|int, mixed>|Closure|null $symbolsMap = null ]) : mixed
Parameters
$defaultLocale : string|null = null
$symbolsMap : array<string|int, mixed>|Closure|null = null

getLocale()

public getLocale() : string
Return values
string

setLocale()

public setLocale(string $locale) : void
Parameters
$locale : string

slug()

Creates a slug for the given string and locale, using appropriate transliteration when needed.

public slug(string $string[, string $separator = '-' ][, string|null $locale = null ]) : AbstractUnicodeString
Parameters
$string : string
$separator : string = '-'
$locale : string|null = null
Return values
AbstractUnicodeString

withEmoji()

public withEmoji([bool|string $emoji = true ]) : static
Parameters
$emoji : bool|string = true

true will use the same locale, false will disable emoji, and a string to use a specific locale

Return values
static

createEmojiTransliterator()

private createEmojiTransliterator(string|null $locale) : EmojiTransliterator|null
Parameters
$locale : string|null
Return values
EmojiTransliterator|null

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
Return values
string|null

        
On this page

Search results