Download the PHP package mpstenson/laravel-advanced-string without Composer
On this page you can find all versions of the php package mpstenson/laravel-advanced-string. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mpstenson/laravel-advanced-string
More information about mpstenson/laravel-advanced-string
Files in mpstenson/laravel-advanced-string
Package laravel-advanced-string
Short Description This application provides advanced string functions beyond what Laravel itself provides.
License MIT
Homepage https://github.com/mpstenson/laravel-advanced-string
Informations about the package laravel-advanced-string
Laravel Advanced String Package
Tested, community maintained, supercharged Laravel string functions.
Laravel Advanced String is a Laravel package that adds advanced string manipulation methods to the built in Str
class that Laravel provides. You get extended functionality on strings such as advanced password generation, data redaction, and more.
The Laravel Advanced String package by default adds macros to the Str
class so your can access the extended functionality in the same class that your other string methods are found in. You can also disable this functionality the in the package config
and use the AdvStr
class directly.
Example
https://github.com/user-attachments/assets/ad4eb551-f383-4ed7-b9db-c44823e637c8
OR...
Table of Contents
- Installation
- Usage
- Available Methods
- advPassword
- charWrap
- emailDomain
- randomPhrase
- randomWord
- readTime
- redactCreditCard
- redactSsn
- splitName
- Testing
- Changelog
- Credits
- License
Installation
You can install the package via composer:
You can publish the config file with:
This is the contents of the published config file:
Usage
The Laravel Advanced String package by default adds macros to the Str
class so your can access the extended functionality immediately
Available Methods
advPassword
Generates a random, secure password.
Parameters:
$length
(int): Length of the password (default: 32)$letters
(bool): Include mixed case letters (default: true)$numbers
(bool): Include numbers (default: true)$symbols
(bool): Include symbols (default: true)$spaces
(bool): Include spaces (default: false)$upperLetters
(bool): Include uppercase letters (default: false)$lowerLetters
(bool): Include lowercase letters (default: false)$exclude
(array): Characters to exclude from the password
Returns:
- string: Generated password
charWrap
Wraps a string at a given number of characters regardless of words.
Parameters:
$string
(string): The string to wrap$length
(int): The number of characters to wrap at (default: 80)
Returns:
- string: The wrapped string
emailDomain
Extracts the domain part of an email address, including subdomains.
Parameters:
$string
(string): The string to extract the email domain from.
Returns:
- string: The email domain from the string
randomPhrase
Returns a random phrase with a configurable delimiter.
Parameters:
$wordCount
(int): The number of words in the phrase.$separator
(string): The separator between words (default: '-').
Returns:
- string: The generated random phrase.
randomWord
Returns a random word.
Parameters:
- none
Returns:
- string: A random word
readTime
Calculates the read time of a string.
Parameters:
$string
(string): The text to calculate read time for$wpm
(int): Words per minute (default: 200)
Returns:
- float: Estimated read time in seconds
redactCreditCard
Redacts credit card numbers in a string.
Parameters:
$string
(string): The string containing credit card numbers to redact$redacted
(string): The string to replace credit card numbers with (default: '****')$exclude
(array): An array of credit card types to exclude from redaction. Possible types: 'mastercard','visa','amex','discover','diners','jcb'
Returns:
- string: The string with credit card numbers redacted
redactSsn
Redacts Social Security Numbers (SSN) in a string.
Parameters:
$string
(string): The string containing SSNs to redact$redacted
(string): The string to replace SSNs with (default: '****')$dashes
(bool): Redact SSNs with dashes (default: true)$noDashes
(bool): Redact SSNs without dashes (default: true)
Returns:
- string: The string with SSNs redacted
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.
Parameters:
$name
(string): The full name to split
Returns:
- array: An associative array containing 'first', 'middle' (if present), and 'last' name
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
- Matt Stenson
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-advanced-string with dependencies
spatie/laravel-package-tools Version ^1.19
illuminate/contracts Version ^10.0||^11.0||^12.0