| Total Complexity | 3 |
| Total Lines | 37 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 13 | final class TokenMask |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * Masks a token to make it incompressible. |
||
| 17 | * Applies a random mask to the token and prepends the mask used to the result making the string always unique. |
||
| 18 | * |
||
| 19 | * @param string $token An unmasked token. |
||
| 20 | * |
||
| 21 | * @throws \Exception if unable to securely generate random bytes |
||
| 22 | * |
||
| 23 | * @return string A masked token. |
||
| 24 | */ |
||
| 25 | 5 | public static function apply(string $token): string |
|
| 31 | } |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Unmasks a token previously masked by `mask`. |
||
| 35 | * |
||
| 36 | * @param string $maskedToken A masked token. |
||
| 37 | * |
||
| 38 | * @return string An unmasked token, or an empty string in case of token format is invalid. |
||
| 39 | */ |
||
| 40 | 6 | public static function remove(string $maskedToken): string |
|
| 52 |