SensitiveValue
class SensitiveValue (View source)
The SensitiveValue class is designed to conceal sensitive information by transforming it into a "sensitive" version, which can be used in logs, error messages, etc.
Methods:
__construct(string $value)Initializes the object with a value to be wrapped and transforms it into a sensitive version using the transformString method.__toString(): string:Returns the original value as a string.__debugInfo(): array:Returns the sensitive value as a string, which can be used for debugging purposes.getValue(): string:Returns the original value.getMaskedValue(): string:Returns the masked (sensitive) value.transformString(string $input): string:Replaces each character of the input string with a special character representing its type (e.g., lowercase letter, uppercase letter, digit, etc.).
Constants
| private LOWERCASE_LETTER |
|
| private UPPERCASE_LETTER |
|
| private SYMBOL |
|
| private NUMBER |
|
| private ANY |
|
Methods
No description
Returns original value as string
Returns the sensitive value as a string
Returns the original value
Returns the masked value
Transforms a string value into a "sensitive" version
Details
__construct(mixed $value)
No description
string
__toString()
Returns original value as string
array
__debugInfo()
Returns the sensitive value as a string
mixed
getValue()
Returns the original value
mixed
getMaskedValue()
Returns the masked value
string
transformString(string $input)
Transforms a string value into a "sensitive" version
The method replaces each character of the input string with a special character that represents its type:
- Lowercase letter: self::LOWERCASE_LETTER
- Uppercase letter: self::UPPERCASE_LETTER
- Digit: self::NUMBER
- Non-alphanumeric character: self::SYMBOL
- Other characters are left unchanged
This method is used to generate a "sensitive" version of a string value, which can be used to conceal sensitive information in logs, error messages, etc.