From 0746926551c33bddee57dda7272daf66449830f7 Mon Sep 17 00:00:00 2001 From: Mallik Hassan Date: Wed, 15 Apr 2026 00:11:07 -0300 Subject: [PATCH 1/3] Doc for Text::mask() --- docs/en/core-libraries/text.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/docs/en/core-libraries/text.md b/docs/en/core-libraries/text.md index 9aa39ac0d9..1a3a73f55a 100644 --- a/docs/en/core-libraries/text.md +++ b/docs/en/core-libraries/text.md @@ -453,4 +453,32 @@ Output: red, orange, yellow, green, blue, indigo and violet +## Text Masking + +### Text::mask() + +`method` Cake\\Utility\\Text::**mask**(string $string, int $offset, ?int $length = null, string $maskCharacter = '*'): string + +Masks a portion of a string with a repeated character. + +Replaces characters starting at `$offset` for `$length` characters with `$maskCharacter`. +If `$length` is `null`, masking continues to the end of the string. +Negative offsets are supported and are calculated from the end of the string. + +```php +$creditCardNumber = '4909090909091234'; + +// Called as TextHelper +echo $this->Text->mask($creditCardNumber, 0, 12, '*'); + +// Called as Text +use Cake\Utility\Text; + +echo Text::mask($creditCardNumber, 0, 12, '*'); +``` + +Output: + + ************1234 + From 9ad965d8a493254d43a72bf0e7c615fcb4625246 Mon Sep 17 00:00:00 2001 From: Mallik Hassan Date: Wed, 15 Apr 2026 08:39:01 -0300 Subject: [PATCH 2/3] Added Text::mask() in migration guide --- docs/en/appendices/5-4-migration-guide.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/en/appendices/5-4-migration-guide.md b/docs/en/appendices/5-4-migration-guide.md index feeae150be..cdcc4617a3 100644 --- a/docs/en/appendices/5-4-migration-guide.md +++ b/docs/en/appendices/5-4-migration-guide.md @@ -71,6 +71,7 @@ version is reported as `unknown`), the header is omitted. - A backwards compatible Container implementation has been added to the core. You can opt-in to use it instead of the current `league/container` implementation by setting `App.container` to `cake` inside your `config/app.php`. See [Dependency Injection Container](../development/dependency-injection) for more details. +- `Text::mask()` was added to mask a portion of a string with a repeated character. See [Text Masking](../core-libraries/text.md#text-masking) for more details. ### Commands From 20b911961d86833af02b02c520e834763c244ca0 Mon Sep 17 00:00:00 2001 From: Mallik Hassan Date: Wed, 15 Apr 2026 09:09:09 -0300 Subject: [PATCH 3/3] Moved function doc under utility --- docs/en/appendices/5-4-migration-guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/appendices/5-4-migration-guide.md b/docs/en/appendices/5-4-migration-guide.md index cdcc4617a3..cfc699ec01 100644 --- a/docs/en/appendices/5-4-migration-guide.md +++ b/docs/en/appendices/5-4-migration-guide.md @@ -71,7 +71,6 @@ version is reported as `unknown`), the header is omitted. - A backwards compatible Container implementation has been added to the core. You can opt-in to use it instead of the current `league/container` implementation by setting `App.container` to `cake` inside your `config/app.php`. See [Dependency Injection Container](../development/dependency-injection) for more details. -- `Text::mask()` was added to mask a portion of a string with a repeated character. See [Text Masking](../core-libraries/text.md#text-masking) for more details. ### Commands @@ -135,6 +134,7 @@ version is reported as `unknown`), the header is omitted. path manipulation. See [Filesystem Utilities](../core-libraries/filesystem.md). - `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. ### Collection