Laravel helper package for speeding up application development
kanekescom/laravel-helperia is a Laravel package for laravel helper package for speeding up application development.
It currently has 0 GitHub stars and 3.670 downloads on Packagist (latest version v2.1.16).
Install it with composer require kanekescom/laravel-helperia.
Discover more Laravel packages by kanekescom
or browse all Laravel packages to compare alternatives.
Last updated
Laravel helper package for speeding up application development.
If you find this package helpful, consider supporting its development:
composer require kanekescom/laravel-helperia
Get method names from a class:
// Get all public methods (excluding constructor, destructor, internal)
method_public(MyClass::class); // Collection of method names
// Get all protected methods
method_protected(MyClass::class);
// Get all private methods
method_private(MyClass::class);
// Get all methods (public, protected, private)
method_all(MyClass::class);
// Also works with object instances
$obj = new MyClass();
method_public($obj); // Same result as using class name
Convert and parse date formats:
// Convert date from one format to another
convert_date_format('01-01-2024', 'd-m-Y', 'Y-m-d'); // "2024-01-01"
convert_date_format('01-01-2024 10:30:00', 'd-m-Y H:i:s', 'Y-m-d H:i:s');
// Parse date string to specified format
parse_date_format('2024-01-01', 'd M Y'); // "01 Jan 2024"
parse_date_format('2024-01-01 10:30:00', 'd M Y H:i:s');
// With default value for invalid/null input
convert_date_format(null, 'd-m-Y', 'Y-m-d', 'N/A'); // "N/A"
convert_date_format('invalid-date', 'd-m-Y', 'Y-m-d', 'fallback'); // "fallback"
parse_date_format('not-a-date', 'Y-m-d', 'default'); // "default"
A base class for wrapping other classes and forwarding method calls:
use Kanekescom\Helperia\Support\ClassExtender;
class MyWrapper extends ClassExtender
{
public function __construct()
{
$this->class = new SomeOtherClass();
}
}
$wrapper = new MyWrapper();
$wrapper->someMethod(); // Calls SomeOtherClass::someMethod()
Trait for forwarding method calls to a wrapped class instance:
use Kanekescom\Helperia\Traits\HasMethodCaller;
class MyClass
{
use HasMethodCaller;
protected $class;
public function __construct($wrappedClass)
{
$this->class = $wrappedClass;
}
}
// Usage
$wrapper = new MyClass(new SomeService());
$wrapper->serviceMethod(); // Forwards to SomeService::serviceMethod()
// Static method calls are also supported
MyClass::staticMethod(); // Forwards static calls
Note: If a method doesn't exist on either the wrapper or wrapped class, a
BadMethodCallExceptionwill be thrown.
composer test
Please see CHANGELOG for more information on what has changed recently.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.