@@ -31,19 +31,19 @@ |
||
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | protected function prepareDrink($orderNumber, $type, $iced){ |
| 34 | - $drink = new Drink($orderNumber, $type, $iced); |
|
| 35 | - return $drink; |
|
| 34 | + $drink = new Drink($orderNumber, $type, $iced); |
|
| 35 | + return $drink; |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | protected function printAction($cold, $orderNr){ |
| 39 | - if($cold){ |
|
| 40 | - $type = 'cold'; |
|
| 41 | - $count = $this->coldDrinkCounter; |
|
| 42 | - }else{ |
|
| 43 | - $type = 'hot'; |
|
| 44 | - $count = $this->hotDrinkCounter; |
|
| 45 | - } |
|
| 46 | - $total = $this->coldDrinkCounter + $this->hotDrinkCounter; |
|
| 39 | + if($cold){ |
|
| 40 | + $type = 'cold'; |
|
| 41 | + $count = $this->coldDrinkCounter; |
|
| 42 | + }else{ |
|
| 43 | + $type = 'hot'; |
|
| 44 | + $count = $this->hotDrinkCounter; |
|
| 45 | + } |
|
| 46 | + $total = $this->coldDrinkCounter + $this->hotDrinkCounter; |
|
| 47 | 47 | echo PEIP_LINE_SEPARATOR."Barista: prepared $type drink (total #$total- $type #$count) for order #$orderNr"; |
| 48 | 48 | flush(); |
| 49 | 49 | } |
@@ -39,7 +39,7 @@ |
||
| 39 | 39 | if($cold){ |
| 40 | 40 | $type = 'cold'; |
| 41 | 41 | $count = $this->coldDrinkCounter; |
| 42 | - }else{ |
|
| 42 | + } else{ |
|
| 43 | 43 | $type = 'hot'; |
| 44 | 44 | $count = $this->hotDrinkCounter; |
| 45 | 45 | } |
@@ -2,40 +2,40 @@ |
||
| 2 | 2 | |
| 3 | 3 | class Order { |
| 4 | 4 | |
| 5 | - protected |
|
| 6 | - $items = array(), |
|
| 7 | - $orderNumber; |
|
| 8 | - protected static $orderCount = 0; |
|
| 5 | + protected |
|
| 6 | + $items = array(), |
|
| 7 | + $orderNumber; |
|
| 8 | + protected static $orderCount = 0; |
|
| 9 | 9 | |
| 10 | - public function __construct(){ |
|
| 11 | - self::$orderCount++; |
|
| 12 | - $this->orderNumber = self::$orderCount; |
|
| 13 | - } |
|
| 10 | + public function __construct(){ |
|
| 11 | + self::$orderCount++; |
|
| 12 | + $this->orderNumber = self::$orderCount; |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | - public function getOrderNumber(){ |
|
| 16 | - return $this->orderNumber; |
|
| 17 | - } |
|
| 15 | + public function getOrderNumber(){ |
|
| 16 | + return $this->orderNumber; |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - public function addItem($type, $number, $iced = false){ |
|
| 20 | - $this->items[] = |
|
| 21 | - array( |
|
| 22 | - 'type' => $type, |
|
| 23 | - 'number' => $number, |
|
| 24 | - 'iced' => $iced |
|
| 25 | - ); |
|
| 26 | - } |
|
| 19 | + public function addItem($type, $number, $iced = false){ |
|
| 20 | + $this->items[] = |
|
| 21 | + array( |
|
| 22 | + 'type' => $type, |
|
| 23 | + 'number' => $number, |
|
| 24 | + 'iced' => $iced |
|
| 25 | + ); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - public function getItems(){ |
|
| 29 | - return $this->items; |
|
| 30 | - } |
|
| 28 | + public function getItems(){ |
|
| 29 | + return $this->items; |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - public function getTotalCount(){ |
|
| 33 | - $x = 0; |
|
| 34 | - foreach($this->items as $item){ |
|
| 35 | - $x += (int)$item['number']; |
|
| 36 | - } |
|
| 37 | - return $x; |
|
| 38 | - } |
|
| 32 | + public function getTotalCount(){ |
|
| 33 | + $x = 0; |
|
| 34 | + foreach($this->items as $item){ |
|
| 35 | + $x += (int)$item['number']; |
|
| 36 | + } |
|
| 37 | + return $x; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | 40 | |
| 41 | 41 | |
@@ -2,14 +2,14 @@ |
||
| 2 | 2 | |
| 3 | 3 | class Delivery { |
| 4 | 4 | |
| 5 | - protected |
|
| 6 | - $deliveredDrinks, |
|
| 7 | - $orderNumber; |
|
| 5 | + protected |
|
| 6 | + $deliveredDrinks, |
|
| 7 | + $orderNumber; |
|
| 8 | 8 | |
| 9 | - public function __construct(array $deliveredDrinks){ |
|
| 10 | - $this->deliveredDrinks = $deliveredDrinks; |
|
| 11 | - $this->orderNumber = $deliveredDrinks[0]->getOrderNumber(); |
|
| 12 | - } |
|
| 9 | + public function __construct(array $deliveredDrinks){ |
|
| 10 | + $this->deliveredDrinks = $deliveredDrinks; |
|
| 11 | + $this->orderNumber = $deliveredDrinks[0]->getOrderNumber(); |
|
| 12 | + } |
|
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | |
@@ -3,30 +3,30 @@ |
||
| 3 | 3 | |
| 4 | 4 | class Drink { |
| 5 | 5 | |
| 6 | - protected |
|
| 7 | - $orderNumber, |
|
| 8 | - $type, |
|
| 9 | - $iced; |
|
| 6 | + protected |
|
| 7 | + $orderNumber, |
|
| 8 | + $type, |
|
| 9 | + $iced; |
|
| 10 | 10 | |
| 11 | - public function __construct($orderNumber, $type, $iced){ |
|
| 12 | - $this->orderNumber = $orderNumber; |
|
| 13 | - $this->type = $type; |
|
| 14 | - $this->iced = $iced; |
|
| 15 | - } |
|
| 11 | + public function __construct($orderNumber, $type, $iced){ |
|
| 12 | + $this->orderNumber = $orderNumber; |
|
| 13 | + $this->type = $type; |
|
| 14 | + $this->iced = $iced; |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | - public function getType(){ |
|
| 18 | - return $this->type; |
|
| 19 | - } |
|
| 17 | + public function getType(){ |
|
| 18 | + return $this->type; |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - public function getIced(){ |
|
| 22 | - return $this->iced; |
|
| 23 | - } |
|
| 21 | + public function getIced(){ |
|
| 22 | + return $this->iced; |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - public function getOrderNumber(){ |
|
| 26 | - return $this->orderNumber; |
|
| 27 | - } |
|
| 25 | + public function getOrderNumber(){ |
|
| 26 | + return $this->orderNumber; |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - public function __sleep() |
|
| 29 | + public function __sleep() |
|
| 30 | 30 | { |
| 31 | 31 | return array('orderNumber', 'type', 'iced'); |
| 32 | 32 | } |
@@ -2,11 +2,11 @@ |
||
| 2 | 2 | |
| 3 | 3 | class DrinkType { |
| 4 | 4 | |
| 5 | - const |
|
| 6 | - ESPRESSO = 'ESPRESSO', |
|
| 7 | - LATTE = 'LATTE', |
|
| 8 | - CAPPUCCINO = 'CAPPUCCINO', |
|
| 9 | - MOCCA = 'MOCCA'; |
|
| 5 | + const |
|
| 6 | + ESPRESSO = 'ESPRESSO', |
|
| 7 | + LATTE = 'LATTE', |
|
| 8 | + CAPPUCCINO = 'CAPPUCCINO', |
|
| 9 | + MOCCA = 'MOCCA'; |
|
| 10 | 10 | |
| 11 | 11 | } |
| 12 | 12 | |
@@ -3,22 +3,22 @@ |
||
| 3 | 3 | |
| 4 | 4 | class Waiter { |
| 5 | 5 | |
| 6 | - protected $orders; |
|
| 6 | + protected $orders; |
|
| 7 | 7 | |
| 8 | - public function prepareDelivery(array $drinks){ |
|
| 9 | - echo PEIP_LINE_SEPARATOR.'Waiter: prepareDelivery: #'.$drinks[0]->getOrderNumber(); |
|
| 10 | - return new Delivery($drinks); |
|
| 11 | - } |
|
| 8 | + public function prepareDelivery(array $drinks){ |
|
| 9 | + echo PEIP_LINE_SEPARATOR.'Waiter: prepareDelivery: #'.$drinks[0]->getOrderNumber(); |
|
| 10 | + return new Delivery($drinks); |
|
| 11 | + } |
|
| 12 | 12 | |
| 13 | 13 | |
| 14 | - public function receiveOrder(Order $order){ |
|
| 15 | - echo PEIP_LINE_SEPARATOR.'Waiter: receiveOrder'; |
|
| 16 | - $this->orders[$order->getOrderNumber()] = $order; |
|
| 17 | - } |
|
| 14 | + public function receiveOrder(Order $order){ |
|
| 15 | + echo PEIP_LINE_SEPARATOR.'Waiter: receiveOrder'; |
|
| 16 | + $this->orders[$order->getOrderNumber()] = $order; |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - public function getOrder($nr){ |
|
| 20 | - return $this->orders[$nr]; |
|
| 21 | - } |
|
| 19 | + public function getOrder($nr){ |
|
| 20 | + return $this->orders[$nr]; |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | 23 | |
| 24 | 24 | } |
@@ -32,11 +32,11 @@ |
||
| 32 | 32 | protected $services = array(); |
| 33 | 33 | |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Constructor. |
|
| 37 | - * |
|
| 38 | - * @param array $parameters An array of parameters |
|
| 39 | - */ |
|
| 35 | + /** |
|
| 36 | + * Constructor. |
|
| 37 | + * |
|
| 38 | + * @param array $parameters An array of parameters |
|
| 39 | + */ |
|
| 40 | 40 | |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -31,13 +31,13 @@ |
||
| 31 | 31 | |
| 32 | 32 | |
| 33 | 33 | /** |
| 34 | - * Calls a method on a service (registered as a callable) with |
|
| 35 | - * content/payload of given message as argument. |
|
| 36 | - * |
|
| 37 | - * @access protected |
|
| 38 | - * @param \PEIP\INF\Message\Message $message message to call the service with it�s content/payload |
|
| 39 | - * @return mixed result of calling the registered service callable with message content/payload |
|
| 40 | - */ |
|
| 34 | + * Calls a method on a service (registered as a callable) with |
|
| 35 | + * content/payload of given message as argument. |
|
| 36 | + * |
|
| 37 | + * @access protected |
|
| 38 | + * @param \PEIP\INF\Message\Message $message message to call the service with it�s content/payload |
|
| 39 | + * @return mixed result of calling the registered service callable with message content/payload |
|
| 40 | + */ |
|
| 41 | 41 | protected function callService(\PEIP\INF\Message\Message $message){
|
| 42 | 42 | $res = NULL; |
| 43 | 43 | if(is_callable($this->serviceCallable)){
|
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | protected function getMessage($object){
|
| 18 | 18 | if($this->channel instanceof \PEIP\INF\Channel\SubscribableChannel){
|
| 19 | 19 | return $object; |
| 20 | - }else{
|
|
| 20 | + } else{
|
|
| 21 | 21 | return $object->getContent()->receive(); |
| 22 | 22 | } |
| 23 | 23 | } |
@@ -63,17 +63,17 @@ discard block |
||
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /** |
| 66 | - * Registers a callable as builder for given node-name |
|
| 67 | - * |
|
| 68 | - * @implements \PEIP\INF\Context\Context |
|
| 69 | - * @access public |
|
| 70 | - * @param string $nodeName the name of the node |
|
| 71 | - * @param callable $callable a callable which creates instances for node-name |
|
| 72 | - */ |
|
| 66 | + * Registers a callable as builder for given node-name |
|
| 67 | + * |
|
| 68 | + * @implements \PEIP\INF\Context\Context |
|
| 69 | + * @access public |
|
| 70 | + * @param string $nodeName the name of the node |
|
| 71 | + * @param callable $callable a callable which creates instances for node-name |
|
| 72 | + */ |
|
| 73 | 73 | public function registerNodeBuilder($nodeName, $callable){
|
| 74 | 74 | $this->nodeBuilders[$nodeName] = $callable; |
| 75 | 75 | } |
| 76 | - /** |
|
| 76 | + /** |
|
| 77 | 77 | * Registers the build-methods for the main-components with this context. |
| 78 | 78 | * Note: This method and subsequent registered methods of this class are |
| 79 | 79 | * candidates for refactoring. Because this class has grown much to large |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | ); |
| 90 | 90 | $plugin = new BasePlugin(); |
| 91 | 91 | foreach($builders as $nodeName => $method){
|
| 92 | - $this->registerNodeBuilder($nodeName, array($this, $method)); |
|
| 92 | + $this->registerNodeBuilder($nodeName, array($this, $method)); |
|
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | if($this->hasService($key)){
|
| 121 | 121 | $service = $this->getService($key); |
| 122 | - }else{
|
|
| 122 | + } else{
|
|
| 123 | 123 | $service = $this->createService($key); |
| 124 | 124 | } |
| 125 | 125 | |
@@ -151,11 +151,11 @@ discard block |
||
| 151 | 151 | )); |
| 152 | 152 | |
| 153 | 153 | return $node; |
| 154 | - }else{
|
|
| 154 | + } else{
|
|
| 155 | 155 | $errorMessage = 'COULD NOT BUILD NODE FOR KEY: '.$key; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - }else{
|
|
| 158 | + } else{
|
|
| 159 | 159 | $errorMessage = 'NO CONFIG FOR KEY: '.$key; |
| 160 | 160 | } |
| 161 | 161 | $this->doFireEvent(self::EVENT_CREATE_SERVICE_ERROR, array( |
@@ -199,10 +199,10 @@ discard block |
||
| 199 | 199 | self::HEADER_NODE => $nodeInstance |
| 200 | 200 | )); |
| 201 | 201 | return $nodeInstance; |
| 202 | - }else{
|
|
| 202 | + } else{
|
|
| 203 | 203 | $errorMessage = 'BUILDER RETURNED NO OBJECT FOR NODE-TYPE: '.$nodeName; |
| 204 | 204 | } |
| 205 | - }else{
|
|
| 205 | + } else{
|
|
| 206 | 206 | $errorMessage = 'NO BUILDER FOUND FOR NODE-TYPE: '.$nodeName; |
| 207 | 207 | } |
| 208 | 208 | |