Skip to content
PHP Ecosystem
Explore

Fqcn

API reference › Debug Core › Helper › Fqcn

final classPHPForge\Debug\Helper\Fqcn
Sourcesrc/Helper/Fqcn.php

Derives the presentation forms of a fully-qualified class name: short name, namespace prefix, two-tone label, and fragment anchor.

MethodDescriptionDefined by
anchor() staticReturns a URL-safe fragment id for a fully-qualified class name, stable across spellings and free of collisions.Fqcn
namespacePart() staticReturns the namespace prefix (everything before the last \, without trailing separator), or '' when none is present.Fqcn
renderLabel() staticRenders the shared two-tone label: a muted namespace prefix followed by a bold short name, with the full value preserved in the title attribute for hover inspection.Fqcn
shortName() staticReturns the segment after the last \ separator, or the full $fqcn when no separator is present.Fqcn
public static function anchor(string $fqcn): string

Returns a URL-safe fragment id for a fully-qualified class name, stable across spellings and free of collisions.

The name is lowercased first because PHP resolves class names case-insensitively, so every spelling of one class must share one anchor. The readable slug collapses each run of characters outside a-z0-9 into a single -, which on its own is not injective (app\A_B and app\A__b both flatten to app-a-b), so the first 8 hexadecimal characters of the sha1 of the lowercased name are appended to keep distinct classes apart; that digest identifies a DOM id and is never used as a security primitive. A name made only of separators leaves no slug and returns the digest alone.

Parameters

ParameterTypeDescription
$fqcnstringFully-qualified class name.

Returns

string: URL-safe fragment id.

public static function namespacePart(string $fqcn): string

Returns the namespace prefix (everything before the last \, without trailing separator), or '' when none is present.

Parameters

ParameterTypeDescription
$fqcnstringFully-qualified class name.

Returns

string: Namespace prefix or ''.

public static function renderLabel(string $value): string

Renders the shared two-tone label: a muted namespace prefix followed by a bold short name, with the full value preserved in the title attribute for hover inspection.

Method-suffixed values such as yii\db\Command::query keep the Class::method pair inside the bold segment; values without a namespace render the bold segment only, and '' collapses to an em dash. A <wbr> between the two segments marks the namespace boundary as the preferred line-break opportunity.

Parameters

ParameterTypeDescription
$valuestringFully-qualified class name, FQCN::method pair, or plain category string.

Returns

string: Two-tone label markup or an em dash for an empty value.

public static function shortName(string $fqcn): string

Returns the segment after the last \ separator, or the full $fqcn when no separator is present.

Parameters

ParameterTypeDescription
$fqcnstringFully-qualified class name.

Returns

string: Short class name.