# Text

> Provides small string conversions shared by the debugger panels.

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

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

Provides small string conversions shared by the debugger panels.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`camel2id()`](#method-camel2id) static | Converts a CamelCase name into a lowercase id with `-` word separators, matching the Yii inflector semantics. | `Text` |
| [`preserveHtmlLineBreaks()`](#method-preserveHtmlLineBreaks) static | Writes each line break of HTML markup as the `&#10;` character reference, leaving the markup itself unchanged. | `Text` |
| [`preserveLineBreaks()`](#method-preserveLineBreaks) static | Escapes text for HTML content and writes each of its line breaks as the `&#10;` character reference. | `Text` |
| [`urlToPath()`](#method-urlToPath) static | Strips the authority from a captured URL for display, retaining its path, non-empty query, and fragment. | `Text` |

## Method details

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

```php
public static function camel2id(string $name): string
```

Converts a CamelCase name into a lowercase id with `-` word separators, matching the Yii inflector semantics.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$name` | `string` | CamelCase name to convert. |

**Returns**

`string`: Lowercase kebab-case id.

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

```php
public static function preserveHtmlLineBreaks(string $html): string
```

Writes each line break of HTML markup as the `&#10;` character reference, leaving the markup itself unchanged.

Use it for markup that is already escaped and carries line breaks only in its text, such as
[`PhpHighlighter::highlightCode()`](/docs/extensions/debug-core/reference/helper/phphighlighter/index.md#method-highlightCode) output; [`Text::preserveLineBreaks()`](/docs/extensions/debug-core/reference/helper/text/index.md#method-preserveLineBreaks) escapes raw text first. `\r\n`
and a lone `\r` become one line break, as the HTML parser reads them.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$html` | `string` | Escaped HTML markup. |

**Returns**

`string`: Markup without raw line breaks.

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

```php
public static function preserveLineBreaks(string $text): string
```

Escapes text for HTML content and writes each of its line breaks as the `&#10;` character reference.

The UI Awesome block builders other than `<pre>` collapse consecutive line breaks in their rendered output, which
drops the blank lines of a multi-line value rendered inside them; a character reference survives that
normalization and still renders as a line break under `white-space: pre-wrap`. `\r\n` and a lone `\r` become one
line break, as the HTML parser reads them.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$text` | `string` | Raw text to render. |

**Returns**

`string`: Escaped HTML content without raw line breaks.

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

```php
public static function urlToPath(string $url): string
```

Strips the authority from a captured URL for display, retaining its path, non-empty query, and fragment.

Unparsable URLs pass through unchanged. This is a display conversion, not URL validation or HTML escaping;
callers must retain the original diagnostic URL and escape the result at the rendering boundary.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$url` | `string` | Captured URL to convert for display. |

**Returns**

`string`: Path with its non-empty query and fragment, or the original URL when unparsable.