PHP code example of jeroen / generic-decorator
1. Go to this page and download the library: Download jeroen/generic-decorator 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/ */
jeroen / generic-decorator example snippets
public function __construct() {
$this->repository = new DoctrineKittenRepository( /* ... */ );
$this->stopWatch = new Stopwatch();
}
public function newProfilingKittenRepository(): KittenRepository {
return DecoratorBuilder::newBuilder( $this->repository )
->withBefore( function() {
$this->stopWatch->start( 'KittenRepository' );
} )
->withAfter( function() {
$this->stopWatch->stop( 'KittenRepository' );
} )
->newDecorator();
}
->withBefore( function() {
$this->logger->alert( 'KittenRepository', [ 'arguments' => func_get_args() ] );
} )