Skip to content
PHP Ecosystem
Explore

Text

API reference › Debug Core › Helper › Text

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

Provides small string conversions shared by the debugger panels.

MethodDescriptionDefined by
camel2id() staticConverts a CamelCase name into a lowercase id with - word separators, matching the Yii inflector semantics.Text
preserveHtmlLineBreaks() staticWrites each line break of HTML markup as the 
 character reference, leaving the markup itself unchanged.Text
preserveLineBreaks() staticEscapes text for HTML content and writes each of its line breaks as the 
 character reference.Text
urlToPath() staticStrips the authority from a captured URL for display, retaining its path, non-empty query, and fragment.Text
public static function camel2id(string $name): string

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

Parameters

ParameterTypeDescription
$namestringCamelCase name to convert.

Returns

string: Lowercase kebab-case id.

public static function preserveHtmlLineBreaks(string $html): string

Writes 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

ParameterTypeDescription
$htmlstringEscaped HTML markup.

Returns

string: Markup without raw line breaks.

public static function preserveLineBreaks(string $text): string

Escapes 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

ParameterTypeDescription
$textstringRaw text to render.

Returns

string: Escaped HTML content without raw line breaks.

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

ParameterTypeDescription
$urlstringCaptured URL to convert for display.

Returns

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