Download the PHP package t-labs-co/laravel-array-macros without Composer
On this page you can find all versions of the php package t-labs-co/laravel-array-macros. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download t-labs-co/laravel-array-macros
More information about t-labs-co/laravel-array-macros
Files in t-labs-co/laravel-array-macros
Package laravel-array-macros
Short Description Laravel Array Macros
License MIT
Homepage https://github.com/t-labs-co/laravel-array-macros
Informations about the package laravel-array-macros
Laravel Array Macros
The Laravel Array Macros
package provides a collection of useful macros for Laravel's Arr helper, extending its functionality to simplify common array operations. These macros are designed to make working with arrays in Laravel more efficient and expressive, reducing boilerplate code and improving readability.
Why Use This Package?
This package is ideal for developers who frequently work with arrays in Laravel and want to simplify their code. It provides a wide range of macros that cover common use cases, making array manipulation more intuitive and concise.
Contact Us
(c) T.Labs & Co. Contact for Work: T. [email protected]
Got a PHP or Laravel project? We're your go-to team! We can help you:
- Architect the perfect solution for your specific needs.
- Get cleaner, faster, and more efficient code.
- Boost your app's performance through refactoring and optimization.
- Build your project the right way with Laravel best practices.
- Get expert guidance and support for all things Laravel.
- Ensure high-quality code through thorough reviews.
- Provide leadership for your team and manage your projects effectively.
- Bring in a seasoned Technical Lead.
Features
firstIf
: Returns the first element of an array if a condition is met.lastIf
: Returns the last element of an array if a condition is met.chunk
: Splits an array into chunks and applies a callback to each chunk.getAnyValues
: Retrieves the first matching value from an array based on a list of keys.hasAllValues
: Checks if all specified values exist in an array.hasAnyValues
: Checks if any of the specified values exist in an array.ifOk
: Returns the array if a condition is met, otherwise returns null.isMissing
: Checks if a key is missing from an array.missing
: Returns a list of keys that are missing from an array.range
: Creates a range of numbers with optional steps.renameKeys
: Renames keys in an array based on a mapping.swap
: Swaps the values of two keys in an array.validate
: Validates all items in an array using a rule or callable.isNumeric
: Checks if all items in an array are numeric. Supports strict mode to ensure only integers and floats are considered numeric.odd
: Filters an array to include only odd numbers. Supports optional sorting in ascending, descending, or no order.even
: Filters an array to include only even numbers. Supports optional sorting in ascending, descending, or no order.
Installation
You can install the package via composer:
Usage
firstIf
Returns the first element of an array if a condition is met.
lastIf
Returns the last element of an array if a condition is met.
chunk
Splits an array into chunks and applies a callback to each chunk.
getAnyValues
Retrieves the first matching value from an array based on a list of keys.
hasAnyValues
Checks if any of the specified values exist in an array.
hasAllValues
Checks if all specified values exist in an array.
ifOk
Returns the array if a condition is met, otherwise returns null.
missing
Returns a list of keys that are missing from an array.
isMissing
Checks if a key is missing from an array.
range
Creates a range of numbers with optional steps.
renameKeys
Renames keys in an array based on a mapping.
swap
Swaps the values of two keys in an array.
validate
Validates all items in an array using a rule or callable.
isNumeric
Checks if all items in an array are numeric. Supports strict mode to ensure only integers and floats are considered numeric.
odd
Filters an array to include only odd numbers. Supports optional sorting in ascending, descending, or no order.
even
Filters an array to include only even numbers. Supports optional sorting in ascending, descending, or no order.
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- T.
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-array-macros with dependencies
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^11.0||^12.0