Debian Codegraph @

lib/3rdParty/composer/spomky-labs/pki-framework/src/X501/StringPrep/MapStep.php

raw symbols SCIP
1 <?php
2
3 declare(strict_types=1);
4
5 namespace SpomkyLabs\Pki\X501\StringPrep;
6
7 use const MB_CASE_LOWER;
8
9 /**
10 * Implements 'Map' step of the Internationalized String Preparation as specified by RFC 4518.
11 *
12 * @see https://tools.ietf.org/html/rfc4518#section-2.2
13 */
14 final class MapStep implements PrepareStep
15 {
16 /**
17 * @param bool $fold Whether to apply case folding
18 */
19 private function __construct(
20 private readonly bool $fold
21 ) {
22 }
23
24 public static function create(bool $fold = false): self
25 {
26 return new self($fold);
27 }
28
29 /**
30 * @param string $string UTF-8 encoded string
31 */
32 public function apply(string $string): string
33 {
34 // @todo Implement character mappings
35 if ($this->fold) {
36 $string = mb_convert_case($string, MB_CASE_LOWER, 'UTF-8');
37 }
38 return $string;
39 }
40 }