Skip to content

Slugger

Turns a fully-qualified name into the URL path its page lives at.

A directory per namespace segment below the framework root, then the class name in kebab case: Quiote\Routing\Compiler\TriadViewResolver becomes routing/compiler/triad-view-resolver. Nesting by namespace rather than flattening is what keeps two classes that share a short name apart.

final class Slugger

SourceSlug/Slugger.php
MethodDescription
forClass(string $fqcn): stringThe page path for a class, relative to the reference root and without an extension.
forNamespace(string $namespace): stringThe page path for a namespace’s index, relative to the reference root.
kebab(string $identifier): stringConverts one identifier to kebab case.

public function forClass(string $fqcn): string

The page path for a class, relative to the reference root and without an extension.

ParameterTypeDescription
$fqcnstring

Returns string

public function forNamespace(string $namespace): string

The page path for a namespace’s index, relative to the reference root.

ParameterTypeDescription
$namespacestring

Returns string

public function kebab(string $identifier): string

Converts one identifier to kebab case.

Acronyms are folded to ordinary capitalised words first, so the boundary rule below never has to reason about a run of capitals that is really one word.

ParameterTypeDescription
$identifierstring

Returns string