# BaseLineBreakNormalizer

> Base class for line break normalization utilities.

[API reference](/docs/api/index.md) › [HTML Helper](/docs/extensions/html-helper/reference/index.md) › [Base](/docs/extensions/html-helper/reference/base/index.md) › BaseLineBreakNormalizer

| abstract class | `UIAwesome\Html\Helper\Base\BaseLineBreakNormalizer` |
| --- | --- |
| Source | [`src/Base/BaseLineBreakNormalizer.php`](https://github.com/ui-awesome/html-helper/blob/main/src/Base/BaseLineBreakNormalizer.php#L15) |

1 subclass:

- [`UIAwesome\Html\Helper\LineBreakNormalizer`](/docs/extensions/html-helper/reference/linebreaknormalizer/index.md)

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

| Method | Description | Defined by |
| --- | --- | --- |
| [`normalize()`](#method-normalize) static | Collapses two or more consecutive line breaks into a single `\n`. | `BaseLineBreakNormalizer` |

## Method details

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

```php
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**

| Parameter | Type | Description |
| --- | --- | --- |
| `$content` | `string\|null` | Text to normalize. Pass `null` or `''` to return `''`. |

**Returns**

`string`: Normalized text with repeated line break groups collapsed.