assessmentee.com

Home | Start test | Contact
 

Activerecord | Adapter | Decorator | DependencyInjectionContainer | Facade | Factory | Hydration | Inheritance | Iterator | Mapper | MVC | Observer | Prototype | Proxy | Registry | ServiceLocator | Singleton | Specification | Strategy | TableGateway | ZF1_TableGateway | ZF2_TableGateway |




    <?php
/*
 * Adapter (wrapper) design pattern
 *
 *
 */

class Shop {

    public $shopName = 'My shop';

    public function getShop(){
        return $this->shopName;
    }
}

class ShopAdapter {
    protected $shop;

    public function __construct(shop $shop) {
        $this->shop = $shop;
    }

    public function getShopName(){
        return $this->shop->getShop();
    }
}



$shopAdapter = new ShopAdapter(new Shop());

echo $shopAdapter->getShopName();


?>


    

Outputs:


My shop



 

© 2017 assessmentee.com