antonioprimera / php-helpers
A lightweight set of php helpers, providing some missing or hard to achieve functionality, without the need to import some larger packages
Requires
- php: ^8.1
Requires (Dev)
- pestphp/pest: ^2.20
- spatie/ray: ^1.28
This package is auto-updated.
Last update: 2024-10-22 15:45:11 UTC
README
This is a lightweight set of php helpers, providing some missing or hard to achieve functionality in PHP, without the need to import some larger packages. This package is intended to be used in PHP Packages and projects, which are not using a framework like Laravel or Symfony (which already provide these functionalities).
Helpers
Array Helpers
arrayMap($array, $callback)
- Maps an array using a callback function, preserving the keysarrayMapWithKeys($array, $callback)
- Maps an array using a callback function, allowing you to also change the keys
String Helpers
- kebabCase($string) - Converts a string to kebab-case
- classBasename($classOrObject) - Returns the class name without the namespace
Installation
You can install the package via composer:
composer require antonioprimera/php-helpers
Contributing
Please be free to contribute to this package by submitting a pull request with any useful helper functions you might have. Please make sure to add tests for any new functionality.
This package will only contain basic helper functions, which are not already provided by PHP itself or which are hard to achieve in just one line with the built-in functions.
Credits
License
The MIT License (MIT). Please see License File for more information.