Laravel Packages

Laravel Advanced String Package

Published

Welcome to the first episode of a new "Creator Spotlight" video series where we interview Laravel developers about the things they are creating. Today we talk with Matt Stenson who created a Laravel Advanced String package that adds extra advanced string manipulation methods to the built-in Str class. This package provides extended functionality on strings, such as advanced password generation, data redaction, and more.

Available Methods

The String methods this package includes are:

advPassword

Generates a random, secure password.

public static function advPassword(
$length = 32,
$letters = true,
$numbers = true,
$symbols = true,
$spaces = false,
$upperLetters = false,
$lowerLetters = false,
$exclude = []
)

charWrap

Wraps a string at a given number of characters regardless of words.

public static function charWrap(
$string,
$length = 80
)

emailDomain

Extracts the domain part of an email address, including subdomains.

public static function emailDomain(
$string
)

readTime

Calculates the read time of a string.

public static function readTime(
$string,
$wpm = 200
)

redactCreditCard

Redacts credit card numbers in a string.

public static function redactCreditCard(
$string,
$redacted = '********',
$exclude = []
)

redactSsn

Redacts Social Security Numbers (SSN) in a string.

public static function redactSsn(
$string,
$redacted = '********',
$dashes = true,
$noDashes = true
)

splitName

Splits a full name into first name, middle name (if present), and last name, removing any prefixes and suffixes. This method can handle both "Firstname Lastname" and "Lastname, Firstname" formats.

public static function splitName(
$name
)

More information

For more info check out the Github Repo for installation details, API docs, and more.

Eric L. Barnes photo

Eric is the creator of Laravel News and has been covering Laravel since 2012.

Sponsored

laravelcloud logo
Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Visit Laravel Cloud

The latest

View all →
CPX: The Composer Package Executor for PHP image

CPX: The Composer Package Executor for PHP

Read article
Laravel AI SDK Adds Human-in-the-Loop Tool Approval image

Laravel AI SDK Adds Human-in-the-Loop Tool Approval

Read article
Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals image

Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals

Read article
Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs image

Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs

Read article
Blade Formatting in Laravel Pint image

Blade Formatting in Laravel Pint

Read article
Inertia DevTools Is Now on the Chrome Web Store image

Inertia DevTools Is Now on the Chrome Web Store

Read article