Looking to hire Laravel developers? Try LaraJobs

laravel-string-kit maintained by mohammad-zarifiyan

Description
Extends Laravel's Str and Stringable classes with additional string utilities.
Last update
2026/07/03 19:47 (dev-master)
Links
Downloads
2
Tags

Comments
comments powered by Disqus

Introduction

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'