PHP code example of koine / decorator

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

    

koine / decorator example snippets



class Product
{
    public function getPrice()
    {
        return 123.99;
    }

    public function getName()
    {
        return "Product Name";
    }
}

class ProductDecorator extends \Koine\Decorator
{
    public function getPrice()
    {
        return 'US ' . $this->object->getPrice();
    }
}

$product   = new Product;
$decorator = new ProductDecorator($product);

$decorator->getName();  // Product Name
$decorator->getPrice(); // US 123.99