| Total Complexity | 3 |
| Total Lines | 31 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); |
||
| 11 | final class TokenMask |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * Masks a token to make it uncompressible. |
||
| 15 | * Applies a random mask to the token and prepends the mask used to the result making the string always unique. |
||
| 16 | * @param string $token An unmasked token. |
||
| 17 | * @return string A masked token. |
||
| 18 | * @throws \Exception if unable to securely generate random bytes |
||
| 19 | */ |
||
| 20 | 5 | public static function apply(string $token): string |
|
| 25 | } |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Unmasks a token previously masked by `mask`. |
||
| 29 | * @param string $maskedToken A masked token. |
||
| 30 | * @return string An unmasked token, or an empty string in case of token format is invalid. |
||
| 31 | */ |
||
| 32 | 6 | public static function remove(string $maskedToken): string |
|
| 44 |