diff --git a/docs/en/appendices/5-4-migration-guide.md b/docs/en/appendices/5-4-migration-guide.md index 3ab9a579c8..a7440c2660 100644 --- a/docs/en/appendices/5-4-migration-guide.md +++ b/docs/en/appendices/5-4-migration-guide.md @@ -156,6 +156,7 @@ version is reported as `unknown`), the header is omitted. - `Security::encrypt()` can now be configured to use longer keys with separate encryption and authentication keys that are derived from the provided key. You can set `Security.encryptWithRawKey` to enable this behavior. See [here](https://github.com/cakephp/cakephp/pull/19325) for more details. - Added `Text::mask()` method which masks a portion of a string with a repeated character. See [Text Masking](../core-libraries/text.md#text-masking) for more details. +- Added `Text::maskValue()` method which masks all occurrences of given substrings within a string using a repeated character. See [Text Masking](../core-libraries/text.md#text-masking) for more details. ### View diff --git a/docs/en/core-libraries/text.md b/docs/en/core-libraries/text.md index 1a3a73f55a..ff8703372e 100644 --- a/docs/en/core-libraries/text.md +++ b/docs/en/core-libraries/text.md @@ -481,4 +481,24 @@ Output: ************1234 +### Text::maskValue() + +`method` Cake\\Utility\\Text::**maskValue**(string $string, array $needles, string $maskCharacter = '*'): string + +Masks all occurrences of given substring(s) within a string using a repeated character. +Each occurrence of the provided substring(s) will be replaced by a sequence of the masking character. + +```php +// Called as TextHelper +echo $this->Text->maskValue('4111111111111234', ['411', '112'], '*'); + +// Called as Text +use Cake\Utility\Text; + +echo Text::maskValue('4111111111111234', ['411', '112'], '*'); +``` + +Output: + + ***11111111***34