Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/en/appendices/5-4-migration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,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

Expand Down
28 changes: 28 additions & 0 deletions docs/en/core-libraries/text.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

<!-- end-text -->