<?php
 declare(strict_types=1); namespace SpomkyLabs\Pki\X501\StringPrep; final class InsignificantNonSubstringSpaceStep implements PrepareStep { public function apply(string $string): string { if (preg_match('/^\p{Zs}*$/u', $string) === 1) { return '  '; } $string = preg_replace('/^\p{Zs}+/u', '', $string); $string = preg_replace('/\p{Zs}+$/u', '', (string) $string); $string = preg_replace('/\p{Zs}+/u', '  ', (string) $string); return " {$string} "; } } 