# Fqcn

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

[API reference](/docs/api/index.md) › [Debug Core](/docs/extensions/debug-core/reference/index.md) › [Helper](/docs/extensions/debug-core/reference/helper/index.md) › Fqcn

| final class | `PHPForge\Debug\Helper\Fqcn` |
| --- | --- |
| Source | [`src/Helper/Fqcn.php`](https://github.com/php-forge/debug-core/blob/main/src/Helper/Fqcn.php#L21) |

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

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`anchor()`](#method-anchor) static | Returns a URL-safe fragment id for a fully-qualified class name, stable across spellings and free of collisions. | `Fqcn` |
| [`namespacePart()`](#method-namespacePart) static | Returns the namespace prefix (everything before the last `\`, without trailing separator), or `''` when none is present. | `Fqcn` |
| [`renderLabel()`](#method-renderLabel) static | 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. | `Fqcn` |
| [`shortName()`](#method-shortName) static | Returns the segment after the last `\` separator, or the full `$fqcn` when no separator is present. | `Fqcn` |

## Method details

### anchor() <span id="method-anchor"></span>

```php
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**

| Parameter | Type | Description |
| --- | --- | --- |
| `$fqcn` | `string` | Fully-qualified class name. |

**Returns**

`string`: URL-safe fragment id.

### namespacePart() <span id="method-namespacePart"></span>

```php
public static function namespacePart(string $fqcn): string
```

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

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$fqcn` | `string` | Fully-qualified class name. |

**Returns**

`string`: Namespace prefix or `''`.

### renderLabel() <span id="method-renderLabel"></span>

```php
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**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `string` | Fully-qualified class name, `FQCN::method` pair, or plain category string. |

**Returns**

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

### shortName() <span id="method-shortName"></span>

```php
public static function shortName(string $fqcn): string
```

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

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$fqcn` | `string` | Fully-qualified class name. |

**Returns**

`string`: Short class name.