Skip to content

Commit a8649f0

Browse files
committed
Doc for maskValue() function
1 parent 57513e8 commit a8649f0

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

docs/en/appendices/5-4-migration-guide.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ version is reported as `unknown`), the header is omitted.
156156
- `Security::encrypt()` can now be configured to use longer keys with separate encryption and authentication keys that are derived from the provided key.
157157
You can set `Security.encryptWithRawKey` to enable this behavior. See [here](https://github.com/cakephp/cakephp/pull/19325) for more details.
158158
- 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.
159+
- 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.
159160

160161
### View
161162

docs/en/core-libraries/text.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,20 +465,26 @@ Replaces characters starting at `$offset` for `$length` characters with `$maskCh
465465
If `$length` is `null`, masking continues to the end of the string.
466466
Negative offsets are supported and are calculated from the end of the string.
467467

468+
### Text::maskValue()
469+
470+
`method` Cake\\Utility\\Text::**maskValue**(string $string, array $needles, string $maskCharacter = '*'): string
471+
472+
Masks all occurrences of given substring(s) within a string using a repeated character.
473+
Each occurrence of the provided substring(s) will be replaced by a sequence of the masking character.
474+
468475
```php
469-
$creditCardNumber = '4909090909091234';
470476

471477
// Called as TextHelper
472-
echo $this->Text->mask($creditCardNumber, 0, 12, '*');
478+
echo $this->Text->maskValue('4111111111111234', ['411', '112'], '*');
473479

474480
// Called as Text
475481
use Cake\Utility\Text;
476482

477-
echo Text::mask($creditCardNumber, 0, 12, '*');
483+
echo Text::maskValue('4111111111111234', ['411', '112'], '*');
478484
```
479485

480486
Output:
481487

482-
************1234
488+
***11111111***34
483489

484490
<!-- end-text -->

0 commit comments

Comments
 (0)