Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
/*
4
 * This file is part of the league/commonmark package.
5
 *
6
 * (c) Colin O'Dell <colinodell@gmail.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
 
12
declare(strict_types=1);
13
 
14
namespace League\CommonMark\Normalizer;
15
 
16
/***
17
 * Normalize text input using the steps given by the CommonMark spec to normalize labels
18
 *
19
 * @see https://spec.commonmark.org/0.29/#matches
20
 *
21
 * @psalm-immutable
22
 */
23
final class TextNormalizer implements TextNormalizerInterface
24
{
25
    /**
26
     * {@inheritDoc}
27
     *
28
     * @psalm-pure
29
     */
30
    public function normalize(string $text, array $context = []): string
31
    {
32
        // Collapse internal whitespace to single space and remove
33
        // leading/trailing whitespace
34
        $text = \preg_replace('/[ \t\r\n]+/', ' ', \trim($text));
35
        \assert(\is_string($text));
36
 
37
        return \mb_convert_case($text, \MB_CASE_FOLD, 'UTF-8');
38
    }
39
}