Skip to content

Extension points

phil/slug

The library is plain PHP and declares no service. Its one port is the slugger, and it is changed by decoration.

Slugger

Phil\Slug\Slugger — turns a text into a Slug. See Reference.

MethodContract
slug(string $text): SlugA valid slug, whatever the text; InvalidSlug when the text holds no letter or digit a slug can be made of
PointHow
Transliteration and lengthnew TransliteratingSlugger($locale, $maxLength)
Changing what a slugger givesA decorator: a class implementing Slugger that receives the slugger it wraps, calls it, and changes the text before or the slug after; LeadingWordsRemoved is one
One slugger per useSluggers, a slugger by name and a default one: titles, file names, directory entries each get theirs

Slug::fromString() checks and never fixes: a decorator returns a slug built by the slugger it wraps, or one that already follows the rules.