ayedev / macro
Enables macro functions for any class
1.0.1
2017-02-11 03:53 UTC
Requires
- php: >=5.5.9
This package is not auto-updated.
Last update: 2024-11-07 21:50:29 UTC
README
Enables dynamically adding functions to any class
Install:
Via composer:
$ composer require ayedev/macro
Usage:
// Import Trait
use Ayedev\Macro\MacroTrait;
// Normal Class
class SimpleClass
{
// Use Trait
use MacroTrait;
}
// Define Macro
SimpleClass::macro( 'getTime', function()
{
// Return
return time();
} );
// Create Instance
$simple = new SimpleClass;
// Print
echo $simple->getTime();
// OUTPUT =>s 1486740611