Skip to content
PHP Ecosystem
Explore

BaseLineBreakNormalizer

API reference › HTML Helper › Base › BaseLineBreakNormalizer

abstract classUIAwesome\Html\Helper\Base\BaseLineBreakNormalizer
Sourcesrc/Base/BaseLineBreakNormalizer.php
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.

MethodDescriptionDefined by
normalize() staticCollapses two or more consecutive line breaks into a single \n.BaseLineBreakNormalizer
public static function normalize(string|null $content): string

Collapses 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

ParameterTypeDescription
$contentstring|nullText to normalize. Pass null or '' to return ''.

Returns

string: Normalized text with repeated line break groups collapsed.