DEV Community

Cover image for Laravel Fluent Str - 48 Methods [πŸš€ 10 MINUTES!]
Clean Code Studio
Clean Code Studio

Posted on • Edited on

Laravel Fluent Str - 48 Methods [πŸš€ 10 MINUTES!]

Twitter Follow


Did you know I have a newsletter? πŸ“¬

If you want to get notified when I publish new blog posts or make major project announcements, head over to https://cleancodestudio.paperform.co/


πŸš€ 10 MINUTES. EVERY LARAVEL FLUENT STRING METHOD (THATS 48 METHODS!)


It's nice when your developer experience, and over all work flow convenience, is improved with features purely meant to make your life better. With Laravel 7's New Fluent String Feature, you can access almost every single Str facade method - fluently!

Upper

Str::of('hello world')->upper();

// HELLO WORLD
Enter fullscreen mode Exit fullscreen mode

Camel

Str::of('HELLO WORLD')->camel();

// HelloWorld
Enter fullscreen mode Exit fullscreen mode

Lower

Str::of('HelloWorld')->lower();

// helloworld
Enter fullscreen mode Exit fullscreen mode

Kebab

Str::of('hello world')->kebab();

// hello-world
Enter fullscreen mode Exit fullscreen mode

Title

Str::of('hello-world')->title();

// Hello World
Enter fullscreen mode Exit fullscreen mode

Snake

Str::of('Hello World')->snake();

// hello_world
Enter fullscreen mode Exit fullscreen mode

Studly

Str::of('hello_world')->studly();

// HelloWorld
Enter fullscreen mode Exit fullscreen mode

ucfirst

Str::of('hello world')->ucfirst();

// Hello world
Enter fullscreen mode Exit fullscreen mode

Plural

Str::of('hello world')->plural();

// hello worlds
Enter fullscreen mode Exit fullscreen mode

Singular

Str::of('hello worlds')->singular();

// hello world
Enter fullscreen mode Exit fullscreen mode

Slug

Str::of('hello world')->slug();

// hello-world
Enter fullscreen mode Exit fullscreen mode

Exactly

is

isNotEmpty

isEmpty

whenEmpty

startsWith

endsWith

contains

containsAll

substr

before

rtrim

after

ltrim

beforeLast

trim

afterLast

dirName

basename

replace

replaceArray

replaceLast

replaceFirst

replaceMatches

finish

start

append

prepend

isAscii

ascii

explode

length

limit

words

split

match

matchAll

Clean Code
Clean Code Studio



Did you know I have a newsletter? πŸ“¬

If you want to get notified when I publish new blog posts or make major project announcements, head over to https://cleancodestudio.paperform.co/

Top comments (1)

Collapse
 
cleancodestudio profile image
Clean Code Studio