mohammad-zarifiyan / laravel-string-kit
Extends Laravel's Str and Stringable classes with additional string utilities.
Package info
github.com/MohammadZarifiyan/Laravel-String-Kit
pkg:composer/mohammad-zarifiyan/laravel-string-kit
Requires
- php: >=8.1
- ext-intl: *
- laravel/framework: >=7
- mohammad-zarifiyan/laravel-locale-kit: ^1.0
This package is auto-updated.
Last update: 2026-06-29 08:49:35 UTC
README
Laravel String Kit extends Laravel's Str and Stringable classes with additional string utilities.
Currently, the package provides methods for detecting text direction and converting Unicode decimal digits from any supported writing system to ASCII digits.
All methods are also available on Laravel's Stringable class.
Installation
Install the package via Composer:
composer require mohammad-zarifiyan/laravel-string-kit:^1.0
Usage
textDirection()
Determines the writing direction of a string.
The method ignores whitespace, punctuation, and digits before detecting the writing direction.
use Illuminate\Support\Str; Str::textDirection('Hello World');
Result:
'ltr'
use Illuminate\Support\Str; Str::textDirection('سلام دنیا');
Result:
'rtl'
If the string contains only digits, punctuation, or whitespace, the method returns:
'ltr'
If the writing direction cannot be determined, the method returns:
null
replaceDigitsWithAscii()
Converts Unicode decimal digits from any supported writing system to ASCII digits.
use Illuminate\Support\Str; Str::replaceDigitsWithAscii('سال ۲۰۲۶');
Result:
'سال 2026'
Another example:
use Illuminate\Support\Str; Str::replaceDigitsWithAscii('१२३٤۵6');
Result:
'123456'