From 818566dde09ac11dfcacf800ecb0569cc12c4246 Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 27 Mar 2019 11:39:18 +0200 Subject: [PATCH] It is not an exercise but solution! --- Prototype/exercise.php | 31 +++---------------------------- 1 file changed, 3 insertions(+), 28 deletions(-) diff --git a/Prototype/exercise.php b/Prototype/exercise.php index a995634..c9a7407 100644 --- a/Prototype/exercise.php +++ b/Prototype/exercise.php @@ -1,5 +1,4 @@ productPrototype; - $product->initialize($code); + // @TODO create an actual $product, and initialize it $output[] = $product->getShopProductCode() . ' - ' . $product->getShopDescription(); } return implode(PHP_EOL, $output); @@ -22,33 +20,13 @@ public function getShopProductCode(); public function getShopDescription(); } } - namespace MyCompanyShop { use ShopingCartFramework\ProductInterface; - class MyShopProduct implements ProductInterface { - protected $productService = array(); - protected $code, $description; - public function __construct(\Closure $productService) { - $this->productService = $productService; - } - public function initialize($code) { - $this->code = $code; - $this->description = call_user_func($this->productService, $code); - } - public function getShopProductCode() { - return $this->code; - } - public function getShopDescription() { - return $this->description; - } - } - + // @TODO implement MyShopProduct prototype } - namespace { use ShopingCartFramework\Shop; use MyCompanyShop\MyShopProduct; - $mockWebService = function($code) { static $data = [ 'BumperSticker1' => 'Cool bumper sticker', @@ -56,10 +34,7 @@ public function getShopDescription() { ]; return $data[$code]; }; - $shop = new Shop(new MyShopProduct($mockWebService)); - $productsToList = ['BumperSticker1', 'CoffeeTableBook5']; - header('content-type: plain/text'); echo $shop->listProducts($productsToList); // simulation of Shopping Cart Listings Page -} \ No newline at end of file +}