1. Go to this page and download the library: Download aimeos/macro library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
aimeos / macro example snippets
// original code
class Order
{
use Aimeos\Macro\Macroable;
private $id = '123';
public function getOrderNumber()
{
$fcn = static::macro( 'orderNumber' );
return $fcn ? $fcn( $this->id ) : $this->id;
}
};
// user code
Order::macro( 'orderNumber', function( string $id ) {
return date( 'Y' ) . '-' . $id;
} );
(new Order)->getOrderNumber(); // now returns '2020-123'
// original code
class A
{
use Aimeos\Macro\Macroable;
private $name = 'A';
};
// original code
class A
{
use Aimeos\Macro\Macroable;
public function do() {
return static::macro( 'concat' )( [1, 2, 3] );
}
};
class B extends A {};
class C extends A {};
// original code
class A
{
use Aimeos\Macro\Macroable;
protected function getName( $prefix )
{
return $prefix . 'A';
}
};
class B extends A
{
public function do()
{
return $this->call( 'getName', 'B-' );
}
};
// user code
(new B)->do(); // returns 'B-A'
A::macro( 'getName', function( $prefix ) {
return $this->getName( $prefix ) . '-123';
} );
(new B)->do(); // returns 'B-A-123'
class A
{
use Aimeos\Macro\Macroable;
};
// add macro
A::macro( 'test', function() {
return 'test';
} );
// remove macro
A::unmacro( 'test' );
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.