| 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 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
final class MapStep implements PrepareStep |
| 15 |
{ |
| 16 |
|
| 17 |
|
| 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 |
|
| 31 |
|
| 32 |
public function apply(string $string): string |
| 33 |
{ |
| 34 |
|
| 35 |
if ($this->fold) { |
| 36 |
$string = mb_convert_case($string, MB_CASE_LOWER, 'UTF-8'); |
| 37 |
} |
| 38 |
return $string; |
| 39 |
} |
| 40 |
} |