Completed
Push — v1.ns ( 31020d...499c60 )
by Timo
04:35 queued 01:07
created
examples/Cafe/lib/messaging/DrinkRouter.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,14 +1,14 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class DrinkRouter 
4
-	extends PEIP_ABS_Router {
4
+    extends PEIP_ABS_Router {
5 5
 	
6
-	protected function selectChannels(PEIP_INF_Message $message){
7
-		$order = $message->getContent();
8
-		$channelName = $order['iced']  ? 'coldDrinks' : 'hotDrinks';
9
-		echo PEIP_LINE_SEPARATOR."DrinkRouter: routed to channel: $channelName";
10
-		return $channelName;
11
-	}	
6
+    protected function selectChannels(PEIP_INF_Message $message){
7
+        $order = $message->getContent();
8
+        $channelName = $order['iced']  ? 'coldDrinks' : 'hotDrinks';
9
+        echo PEIP_LINE_SEPARATOR."DrinkRouter: routed to channel: $channelName";
10
+        return $channelName;
11
+    }	
12 12
 
13 13
 	
14 14
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3,9 +3,9 @@
 block discarded – undo
3 3
 class DrinkRouter 
4 4
 	extends PEIP_ABS_Router {
5 5
 	
6
-	protected function selectChannels(PEIP_INF_Message $message){
6
+	protected function selectChannels(PEIP_INF_Message $message) {
7 7
 		$order = $message->getContent();
8
-		$channelName = $order['iced']  ? 'coldDrinks' : 'hotDrinks';
8
+		$channelName = $order['iced'] ? 'coldDrinks' : 'hotDrinks';
9 9
 		echo PEIP_LINE_SEPARATOR."DrinkRouter: routed to channel: $channelName";
10 10
 		return $channelName;
11 11
 	}	
Please login to merge, or discard this patch.
examples/Cafe/lib/messaging/DrinkAggregator.php 2 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -1,38 +1,38 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class DrinkAggregator 
4
-	extends PEIP_Pipe {
4
+    extends PEIP_Pipe {
5 5
 
6
-	protected $orders = array();
7
-	protected $preparedDrinks = array();
6
+    protected $orders = array();
7
+    protected $preparedDrinks = array();
8 8
 	
9
-	public function __construct(PEIP_INF_Channel $inputChannel, PEIP_INF_Channel $outputChannel = NULL){
10
-		$this->setInputChannel($inputChannel);
11
-		if(is_object($outputChannel)){
12
-			$this->setOutputChannel($outputChannel);	
13
-		}
14
-		$this->registerCommand('ADD_ORDER', array($this, 'receiveOrder'));
15
-	}
9
+    public function __construct(PEIP_INF_Channel $inputChannel, PEIP_INF_Channel $outputChannel = NULL){
10
+        $this->setInputChannel($inputChannel);
11
+        if(is_object($outputChannel)){
12
+            $this->setOutputChannel($outputChannel);	
13
+        }
14
+        $this->registerCommand('ADD_ORDER', array($this, 'receiveOrder'));
15
+    }
16 16
 
17
-	protected function doReply(PEIP_INF_Message $message){
18
-		$drink = $message->getContent();
19
-		$nr = $drink->getOrderNumber();
20
-		if(!isset($this->preparedDrinks[$nr])){
21
-			$this->preparedDrinks[$nr] = array();
22
-		}
23
-		$this->preparedDrinks[$drink->getOrderNumber()][] = $drink;
24
-		if(isset($this->orders[$nr]) 
25
-			&& $this->orders[$nr]->getTotalCount() == count($this->preparedDrinks[$nr])){
26
-			$this->replyMessage($this->preparedDrinks[$nr]);
27
-			unset($this->preparedDrinks[$nr]);
28
-			echo PEIP_LINE_SEPARATOR.'DrinkAggregator : reply #'.$nr;	
29
-		}
30
-	}
17
+    protected function doReply(PEIP_INF_Message $message){
18
+        $drink = $message->getContent();
19
+        $nr = $drink->getOrderNumber();
20
+        if(!isset($this->preparedDrinks[$nr])){
21
+            $this->preparedDrinks[$nr] = array();
22
+        }
23
+        $this->preparedDrinks[$drink->getOrderNumber()][] = $drink;
24
+        if(isset($this->orders[$nr]) 
25
+            && $this->orders[$nr]->getTotalCount() == count($this->preparedDrinks[$nr])){
26
+            $this->replyMessage($this->preparedDrinks[$nr]);
27
+            unset($this->preparedDrinks[$nr]);
28
+            echo PEIP_LINE_SEPARATOR.'DrinkAggregator : reply #'.$nr;	
29
+        }
30
+    }
31 31
 
32
-	public function receiveOrder(Order $order){
33
-		echo PEIP_LINE_SEPARATOR.'DrinkAggregator: received Order';
34
-		$this->orders[$order->getOrderNumber()] = $order;	
35
-	}	
32
+    public function receiveOrder(Order $order){
33
+        echo PEIP_LINE_SEPARATOR.'DrinkAggregator: received Order';
34
+        $this->orders[$order->getOrderNumber()] = $order;	
35
+    }	
36 36
 	
37 37
 
38 38
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -6,30 +6,30 @@
 block discarded – undo
6 6
 	protected $orders = array();
7 7
 	protected $preparedDrinks = array();
8 8
 	
9
-	public function __construct(PEIP_INF_Channel $inputChannel, PEIP_INF_Channel $outputChannel = NULL){
9
+	public function __construct(PEIP_INF_Channel $inputChannel, PEIP_INF_Channel $outputChannel = NULL) {
10 10
 		$this->setInputChannel($inputChannel);
11
-		if(is_object($outputChannel)){
11
+		if (is_object($outputChannel)) {
12 12
 			$this->setOutputChannel($outputChannel);	
13 13
 		}
14 14
 		$this->registerCommand('ADD_ORDER', array($this, 'receiveOrder'));
15 15
 	}
16 16
 
17
-	protected function doReply(PEIP_INF_Message $message){
17
+	protected function doReply(PEIP_INF_Message $message) {
18 18
 		$drink = $message->getContent();
19 19
 		$nr = $drink->getOrderNumber();
20
-		if(!isset($this->preparedDrinks[$nr])){
20
+		if (!isset($this->preparedDrinks[$nr])) {
21 21
 			$this->preparedDrinks[$nr] = array();
22 22
 		}
23 23
 		$this->preparedDrinks[$drink->getOrderNumber()][] = $drink;
24
-		if(isset($this->orders[$nr]) 
25
-			&& $this->orders[$nr]->getTotalCount() == count($this->preparedDrinks[$nr])){
24
+		if (isset($this->orders[$nr]) 
25
+			&& $this->orders[$nr]->getTotalCount() == count($this->preparedDrinks[$nr])) {
26 26
 			$this->replyMessage($this->preparedDrinks[$nr]);
27 27
 			unset($this->preparedDrinks[$nr]);
28 28
 			echo PEIP_LINE_SEPARATOR.'DrinkAggregator : reply #'.$nr;	
29 29
 		}
30 30
 	}
31 31
 
32
-	public function receiveOrder(Order $order){
32
+	public function receiveOrder(Order $order) {
33 33
 		echo PEIP_LINE_SEPARATOR.'DrinkAggregator: received Order';
34 34
 		$this->orders[$order->getOrderNumber()] = $order;	
35 35
 	}	
Please login to merge, or discard this patch.
examples/Cafe/lib/messaging/CafeGateway.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -2,13 +2,13 @@
 block discarded – undo
2 2
 
3 3
 class CafeGateway extends PEIP_Simple_Messaging_Gateway {
4 4
 
5
-	public function placeOrder(Order $order){
6
-		echo "\nCafe: place order #".$order->getOrderNumber();
7
-		$this->send($order);
8
-	}
5
+    public function placeOrder(Order $order){
6
+        echo "\nCafe: place order #".$order->getOrderNumber();
7
+        $this->send($order);
8
+    }
9 9
 	
10
-	public function receiveDelivery(){
11
-		return $this->receive();
12
-	}
10
+    public function receiveDelivery(){
11
+        return $this->receive();
12
+    }
13 13
 
14 14
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2,12 +2,12 @@
 block discarded – undo
2 2
 
3 3
 class CafeGateway extends PEIP_Simple_Messaging_Gateway {
4 4
 
5
-	public function placeOrder(Order $order){
5
+	public function placeOrder(Order $order) {
6 6
 		echo "\nCafe: place order #".$order->getOrderNumber();
7 7
 		$this->send($order);
8 8
 	}
9 9
 	
10
-	public function receiveDelivery(){
10
+	public function receiveDelivery() {
11 11
 		return $this->receive();
12 12
 	}
13 13
 
Please login to merge, or discard this patch.
examples/Cafe/lib/messaging/OrderSplitter.php 2 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -2,20 +2,20 @@
 block discarded – undo
2 2
 
3 3
 class OrderSplitter extends PEIP_ABS_Message_Splitter {
4 4
 
5
-	public function split(PEIP_INF_Message $message){
6
-		$order = $message->getContent();
7
-		$orderItems = $order->getItems();
8
-		$items = array();
9
-		foreach($orderItems as $item){
10
-			$nr = $item['number'];
11
-			unset($item['number']);
12
-			$item['order'] = $order->getOrderNumber();
13
-			for($x = 0; $x < $nr; $x++){
14
-				$items[] = $item;	
15
-			}
16
-		}
17
-		echo PEIP_LINE_SEPARATOR."OrderSplitter: split order #: ".$order->getOrderNumber();
18
-		return $items;
19
-	}
5
+    public function split(PEIP_INF_Message $message){
6
+        $order = $message->getContent();
7
+        $orderItems = $order->getItems();
8
+        $items = array();
9
+        foreach($orderItems as $item){
10
+            $nr = $item['number'];
11
+            unset($item['number']);
12
+            $item['order'] = $order->getOrderNumber();
13
+            for($x = 0; $x < $nr; $x++){
14
+                $items[] = $item;	
15
+            }
16
+        }
17
+        echo PEIP_LINE_SEPARATOR."OrderSplitter: split order #: ".$order->getOrderNumber();
18
+        return $items;
19
+    }
20 20
 	
21 21
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -2,15 +2,15 @@
 block discarded – undo
2 2
 
3 3
 class OrderSplitter extends PEIP_ABS_Message_Splitter {
4 4
 
5
-	public function split(PEIP_INF_Message $message){
5
+	public function split(PEIP_INF_Message $message) {
6 6
 		$order = $message->getContent();
7 7
 		$orderItems = $order->getItems();
8 8
 		$items = array();
9
-		foreach($orderItems as $item){
9
+		foreach ($orderItems as $item) {
10 10
 			$nr = $item['number'];
11 11
 			unset($item['number']);
12 12
 			$item['order'] = $order->getOrderNumber();
13
-			for($x = 0; $x < $nr; $x++){
13
+			for ($x = 0; $x < $nr; $x++) {
14 14
 				$items[] = $item;	
15 15
 			}
16 16
 		}
Please login to merge, or discard this patch.
examples/Cafe/lib/model/Barista.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -31,19 +31,19 @@
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -30,16 +30,16 @@
 block discarded – undo
30 30
         return $this->prepareDrink($orderItem['order'], $orderItem['type'], true);
31 31
     }    
32 32
 	
33
-    protected function prepareDrink($orderNumber, $type, $iced){
33
+    protected function prepareDrink($orderNumber, $type, $iced) {
34 34
     	$drink = new Drink($orderNumber, $type, $iced);	
35 35
     	return $drink;
36 36
     }
37 37
 
38
-    protected function printAction($cold, $orderNr){
39
-    	if($cold){
38
+    protected function printAction($cold, $orderNr) {
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
     	}
Please login to merge, or discard this patch.
examples/Cafe/lib/model/Order.php 2 patches
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -2,40 +2,40 @@
 block discarded – undo
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
 	
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -7,16 +7,16 @@  discard block
 block discarded – undo
7 7
 		$orderNumber;
8 8
 	protected static $orderCount = 0;
9 9
 
10
-	public function __construct(){
10
+	public function __construct() {
11 11
 		self::$orderCount++;
12 12
 		$this->orderNumber = self::$orderCount;
13 13
 	}	
14 14
 
15
-	public function getOrderNumber(){
15
+	public function getOrderNumber() {
16 16
 		return $this->orderNumber;
17 17
 	}
18 18
 	
19
-	public function addItem($type, $number, $iced = false){
19
+	public function addItem($type, $number, $iced = false) {
20 20
 		$this->items[] = 
21 21
 			array(
22 22
 				'type' => $type,
@@ -25,13 +25,13 @@  discard block
 block discarded – undo
25 25
 			);
26 26
 	}
27 27
 
28
-	public function getItems(){
28
+	public function getItems() {
29 29
 		return $this->items;
30 30
 	}
31 31
 
32
-	public function getTotalCount(){
32
+	public function getTotalCount() {
33 33
 		$x = 0;
34
-		foreach($this->items as $item){
34
+		foreach ($this->items as $item) {
35 35
 			$x += (int)$item['number'];
36 36
 		}
37 37
 		return $x;
Please login to merge, or discard this patch.
examples/Cafe/lib/model/Delivery.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -2,14 +2,14 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
 		$deliveredDrinks,
7 7
 		$orderNumber;
8 8
 	
9
-	public function __construct(array $deliveredDrinks){
9
+	public function __construct(array $deliveredDrinks) {
10 10
 		$this->deliveredDrinks = $deliveredDrinks;
11 11
 		$this->orderNumber = $deliveredDrinks[0]->getOrderNumber();
12 12
 	}
Please login to merge, or discard this patch.
examples/Cafe/lib/model/Drink.php 2 patches
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -3,30 +3,30 @@
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,21 +8,21 @@
 block discarded – undo
8 8
 		$type,
9 9
 		$iced;
10 10
 	
11
-	public function __construct($orderNumber, $type, $iced){
11
+	public function __construct($orderNumber, $type, $iced) {
12 12
 		$this->orderNumber = $orderNumber;
13 13
 		$this->type = $type;
14 14
 		$this->iced = $iced;
15 15
 	}
16 16
 
17
-	public function getType(){
17
+	public function getType() {
18 18
 		return $this->type; 
19 19
 	}
20 20
 
21
-	public function getIced(){
21
+	public function getIced() {
22 22
 		return $this->iced; 
23 23
 	}	
24 24
 
25
-	public function getOrderNumber(){
25
+	public function getOrderNumber() {
26 26
 		return $this->orderNumber;
27 27
 	}
28 28
 	
Please login to merge, or discard this patch.
examples/Cafe/lib/model/DrinkType.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -2,11 +2,11 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.