Skip to content

Commit 0746926

Browse files
committed
Doc for Text::mask()
1 parent 14db7d6 commit 0746926

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

docs/en/core-libraries/text.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,4 +453,32 @@ Output:
453453

454454
red, orange, yellow, green, blue, indigo and violet
455455

456+
## Text Masking
457+
458+
### Text::mask()
459+
460+
`method` Cake\\Utility\\Text::**mask**(string $string, int $offset, ?int $length = null, string $maskCharacter = '*'): string
461+
462+
Masks a portion of a string with a repeated character.
463+
464+
Replaces characters starting at `$offset` for `$length` characters with `$maskCharacter`.
465+
If `$length` is `null`, masking continues to the end of the string.
466+
Negative offsets are supported and are calculated from the end of the string.
467+
468+
```php
469+
$creditCardNumber = '4909090909091234';
470+
471+
// Called as TextHelper
472+
echo $this->Text->mask($creditCardNumber, 0, 12, '*');
473+
474+
// Called as Text
475+
use Cake\Utility\Text;
476+
477+
echo Text::mask($creditCardNumber, 0, 12, '*');
478+
```
479+
480+
Output:
481+
482+
************1234
483+
456484
<!-- end-text -->

0 commit comments

Comments
 (0)