BaseLineBreakNormalizer
API reference › HTML Helper › Base › BaseLineBreakNormalizer
1 subclass
Base class for line break normalization utilities.
Collapses repeated line break sequences to a single \n while preserving single line breaks.
See also: https://www.php.net/manual/en/function.preg-replace.php, https://www.pcre.org/current/doc/html/pcre2pattern.html#SEC6.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
normalize() static | Collapses two or more consecutive line breaks into a single \. | BaseLineBreakNormalizer |
Method details
Section titled “Method details”normalize()
Section titled “normalize() ”public static function normalize(string|null $content): stringCollapses two or more consecutive line breaks into a single \n.
Returns '' when $content is null or ''. Preserves single line breaks, including \n and \r\n.
For invalid UTF-8, collapses repeated ASCII line breaks and preserves other bytes.
Parameters
| Parameter | Type | Description |
|---|---|---|
$content | string| | Text to normalize. Pass null or '' to return ''. |
Returns
string: Normalized text with repeated line break groups collapsed.