PHP code example of jedibc / decorator-stack

1. Go to this page and download the library: Download jedibc/decorator-stack 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/ */

    

jedibc / decorator-stack example snippets


$decoratedObject = new Foo\Bar\Decorator1(
	new Foo\Bar\Decorator2(
    	new Foo\Bar\Decorator3(
        	new ObjectToDecorate()
        ), [$someConstuctorArgument])
);

$stack = (new DecoratorStack\Builder('Foo\Bar\DummyInterface'))
	->push('Foo\Bar\Decorator1')
	->push('Foo\Bar\Decorator2', [$someConstuctorArgument])
	->push('Foo\Bar\Decorator3');

$decoratedObject = $stack->resolve(new ObjectToDecorate())