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

__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

Details

__construct(mixed $value)

No description

Parameters

mixed $value

The value to wrap

string __toString()

Returns original value as string

Return Value

string

array __debugInfo()

Returns the sensitive value as a string

Return Value

array

mixed getValue()

Returns the original value

Return Value

mixed

mixed getMaskedValue()

Returns the masked value

Return Value

mixed

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.

Parameters

string $input

The string value to transform

Return Value

string

The transformed string value