Text
API reference › Debug Core › Helper › Text
Provides small string conversions shared by the debugger panels.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
camel2id() static | Converts a CamelCase name into a lowercase id with - word separators, matching the Yii inflector semantics. | Text |
preserveHtmlLineBreaks() static | Writes each line break of HTML markup as the character reference, leaving the markup itself unchanged. | Text |
preserveLineBreaks() static | Escapes text for HTML content and writes each of its line breaks as the character reference. | Text |
urlToPath() static | Strips the authority from a captured URL for display, retaining its path, non-empty query, and fragment. | Text |
Method details
Section titled “Method details”camel2id()
Section titled “camel2id() ”public static function camel2id(string $name): stringConverts 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()
Section titled “preserveHtmlLineBreaks() ”public static function preserveHtmlLineBreaks(string $html): stringWrites each line break of HTML markup as the 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() output; Text::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()
Section titled “preserveLineBreaks() ”public static function preserveLineBreaks(string $text): stringEscapes text for HTML content and writes each of its line breaks as the 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()
Section titled “urlToPath() ”public static function urlToPath(string $url): stringStrips 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.