Completed
Push — v1.ns ( ab319d...410f3f )
by Timo
04:00
created
examples/Cafe/lib/model/Barista.php 1 patch
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.
examples/Cafe/lib/model/Order.php 1 patch
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.
examples/Cafe/lib/model/Delivery.php 1 patch
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.
examples/Cafe/lib/model/Drink.php 1 patch
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.
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.
examples/Cafe/lib/model/Waiter.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -3,22 +3,22 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
examples/Cafe/example.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -46,19 +46,19 @@
 block discarded – undo
46 46
 
47 47
 if($cafe){
48 48
 
49
-	for ($i = 1; $i <= 10; $i++) {
50
-       	// create and place orders
51
-		$order = new Order();
52
-        	$order->addItem("LATTE", 2, false);
53
-        	$order->addItem("MOCCA", 3, true);
54
-        	$cafe->placeOrder($order);
55
-        	// receive drinks
56
-		$drinks = $cafe->receiveDelivery();
49
+    for ($i = 1; $i <= 10; $i++) {
50
+            // create and place orders
51
+        $order = new Order();
52
+            $order->addItem("LATTE", 2, false);
53
+            $order->addItem("MOCCA", 3, true);
54
+            $cafe->placeOrder($order);
55
+            // receive drinks
56
+        $drinks = $cafe->receiveDelivery();
57 57
                 var_dump($drinks);
58
-    	}	
58
+        }	
59 59
 
60 60
 }else{
61
-	throw new RuntimeException('Could not get CafeGateway');
61
+    throw new RuntimeException('Could not get CafeGateway');
62 62
 }
63 63
 
64 64
 
Please login to merge, or discard this patch.
examples/Cafe/lib/messaging/CafeGateway.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -4,13 +4,13 @@
 block discarded – undo
4 4
 
5 5
 class CafeGateway extends SimpleMessagingGateway {
6 6
 
7
-	public function placeOrder(Order $order){
8
-		echo "\nCafe: place order #".$order->getOrderNumber();
9
-		$this->send($order);
10
-	}
7
+    public function placeOrder(Order $order){
8
+        echo "\nCafe: place order #".$order->getOrderNumber();
9
+        $this->send($order);
10
+    }
11 11
 	
12
-	public function receiveDelivery(){
13
-		return $this->receive();
14
-	}
12
+    public function receiveDelivery(){
13
+        return $this->receive();
14
+    }
15 15
 
16 16
 }
Please login to merge, or discard this patch.
examples/Cafe/lib/messaging/DrinkAggregator.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -4,38 +4,38 @@
 block discarded – undo
4 4
 use PEIP\INF\Message\Message;
5 5
 
6 6
 class DrinkAggregator 
7
-	extends \PEIP\Pipe\Pipe {
7
+    extends \PEIP\Pipe\Pipe {
8 8
 
9
-	protected $orders = array();
10
-	protected $preparedDrinks = array();
9
+    protected $orders = array();
10
+    protected $preparedDrinks = array();
11 11
 	
12
-	public function __construct(Channel $inputChannel, Channel $outputChannel = NULL){
13
-		$this->setInputChannel($inputChannel);
14
-		if(is_object($outputChannel)){
15
-			$this->setOutputChannel($outputChannel);	
16
-		}
17
-		$this->registerCommand('ADD_ORDER', array($this, 'receiveOrder'));
18
-	}
12
+    public function __construct(Channel $inputChannel, Channel $outputChannel = NULL){
13
+        $this->setInputChannel($inputChannel);
14
+        if(is_object($outputChannel)){
15
+            $this->setOutputChannel($outputChannel);	
16
+        }
17
+        $this->registerCommand('ADD_ORDER', array($this, 'receiveOrder'));
18
+    }
19 19
 
20
-	protected function doReply(Message $message){
21
-		$drink = $message->getContent();
22
-		$nr = $drink->getOrderNumber();
23
-		if(!isset($this->preparedDrinks[$nr])){
24
-			$this->preparedDrinks[$nr] = array();
25
-		}
26
-		$this->preparedDrinks[$drink->getOrderNumber()][] = $drink;
27
-		if(isset($this->orders[$nr]) 
28
-			&& $this->orders[$nr]->getTotalCount() == count($this->preparedDrinks[$nr])){
29
-			$this->replyMessage($this->preparedDrinks[$nr]);
30
-			unset($this->preparedDrinks[$nr]);
31
-			echo PEIP_LINE_SEPARATOR.'DrinkAggregator : reply #'.$nr;	
32
-		}
33
-	}
20
+    protected function doReply(Message $message){
21
+        $drink = $message->getContent();
22
+        $nr = $drink->getOrderNumber();
23
+        if(!isset($this->preparedDrinks[$nr])){
24
+            $this->preparedDrinks[$nr] = array();
25
+        }
26
+        $this->preparedDrinks[$drink->getOrderNumber()][] = $drink;
27
+        if(isset($this->orders[$nr]) 
28
+            && $this->orders[$nr]->getTotalCount() == count($this->preparedDrinks[$nr])){
29
+            $this->replyMessage($this->preparedDrinks[$nr]);
30
+            unset($this->preparedDrinks[$nr]);
31
+            echo PEIP_LINE_SEPARATOR.'DrinkAggregator : reply #'.$nr;	
32
+        }
33
+    }
34 34
 
35
-	public function receiveOrder(Order $order){
36
-		echo PEIP_LINE_SEPARATOR.'DrinkAggregator: received Order';
37
-		$this->orders[$order->getOrderNumber()] = $order;	
38
-	}	
35
+    public function receiveOrder(Order $order){
36
+        echo PEIP_LINE_SEPARATOR.'DrinkAggregator: received Order';
37
+        $this->orders[$order->getOrderNumber()] = $order;	
38
+    }	
39 39
 	
40 40
 
41 41
 }
Please login to merge, or discard this patch.