@@ -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 | } |
@@ -5,18 +5,18 @@ |
||
5 | 5 | |
6 | 6 | protected $orders; |
7 | 7 | |
8 | - public function prepareDelivery(array $drinks){ |
|
8 | + public function prepareDelivery(array $drinks) { |
|
9 | 9 | echo PEIP_LINE_SEPARATOR.'Waiter: prepareDelivery: #'.$drinks[0]->getOrderNumber(); |
10 | 10 | return new Delivery($drinks); |
11 | 11 | } |
12 | 12 | |
13 | 13 | |
14 | - public function receiveOrder(Order $order){ |
|
14 | + public function receiveOrder(Order $order) { |
|
15 | 15 | echo PEIP_LINE_SEPARATOR.'Waiter: receiveOrder'; |
16 | 16 | $this->orders[$order->getOrderNumber()] = $order; |
17 | 17 | } |
18 | 18 | |
19 | - public function getOrder($nr){ |
|
19 | + public function getOrder($nr) { |
|
20 | 20 | return $this->orders[$nr]; |
21 | 21 | } |
22 | 22 |
@@ -67,9 +67,9 @@ discard block |
||
67 | 67 | Reflection_Pool::getInstance( |
68 | 68 | $object->getContent() |
69 | 69 | ) |
70 | - ), |
|
71 | - $object |
|
72 | - ); |
|
70 | + ), |
|
71 | + $object |
|
72 | + ); |
|
73 | 73 | }else{ |
74 | 74 | throw new \InvalidArgumentException('instance of \PEIP\INF\Event\Event must contain subject'); |
75 | 75 | } |
@@ -78,18 +78,18 @@ discard block |
||
78 | 78 | } |
79 | 79 | } //put your code here |
80 | 80 | |
81 | - /** |
|
82 | - * Creates an event-object with given object as content/subject and notifies |
|
83 | - * all registers listeners of the event. |
|
84 | - * |
|
85 | - * @access public |
|
86 | - * @param string $name name of the event |
|
87 | - * @param object $object the subject of the event |
|
88 | - * @param array $headers headers of the event-object as key/value pairs |
|
89 | - * @param string $eventClass event-class to create instances from |
|
90 | - * @return |
|
91 | - * @see EventBuilder |
|
92 | - */ |
|
81 | + /** |
|
82 | + * Creates an event-object with given object as content/subject and notifies |
|
83 | + * all registers listeners of the event. |
|
84 | + * |
|
85 | + * @access public |
|
86 | + * @param string $name name of the event |
|
87 | + * @param object $object the subject of the event |
|
88 | + * @param array $headers headers of the event-object as key/value pairs |
|
89 | + * @param string $eventClass event-class to create instances from |
|
90 | + * @return |
|
91 | + * @see EventBuilder |
|
92 | + */ |
|
93 | 93 | public function buildAndNotify($name, $object, array $headers = array(), $eventClass = false, $type = false){ |
94 | 94 | if(!$this->hasListeners($name, ($object))){ |
95 | 95 | return false; |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | * @param Callable|PEIP\INF\Handler\Handler $listener event-handler |
28 | 28 | * @return boolean |
29 | 29 | */ |
30 | - public function connect($name, $object, $listener){ |
|
30 | + public function connect($name, $object, $listener) { |
|
31 | 31 | $class = is_object($object) ? get_class($object) : (string)$object; |
32 | - foreach(Reflection::getImplementedClassesAndInterfaces($object) as $cls){ |
|
32 | + foreach (Reflection::getImplementedClassesAndInterfaces($object) as $cls) { |
|
33 | 33 | $reflection = Reflection_Pool::getInstance($class); |
34 | 34 | parent::connect($name, $reflection, $listener); |
35 | 35 | } |
@@ -37,13 +37,13 @@ discard block |
||
37 | 37 | return true; |
38 | 38 | } |
39 | 39 | |
40 | - public function disconnect($name, $object, $listener){ |
|
40 | + public function disconnect($name, $object, $listener) { |
|
41 | 41 | $class = is_object($object) ? get_class($object) : (string)$object; |
42 | 42 | $res = true; |
43 | - foreach(Reflection::getImplementedClassesAndInterfaces($object) as $cls){ |
|
43 | + foreach (Reflection::getImplementedClassesAndInterfaces($object) as $cls) { |
|
44 | 44 | $reflection = Reflection_Pool::getInstance($class); |
45 | 45 | $r = parent::disconnect($name, $reflection, $listener); |
46 | - if(!$r){ |
|
46 | + if (!$r) { |
|
47 | 47 | $res = false; |
48 | 48 | } |
49 | 49 | } |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | * @param \PEIP\INF\Event\Event $object an event object |
59 | 59 | * @return boolean |
60 | 60 | */ |
61 | - public function notify($name, $object){ |
|
62 | - if($object instanceof \PEIP\INF\Event\Event){ |
|
63 | - if(is_object($object->getContent())){ |
|
61 | + public function notify($name, $object) { |
|
62 | + if ($object instanceof \PEIP\INF\Event\Event) { |
|
63 | + if (is_object($object->getContent())) { |
|
64 | 64 | return self::doNotify( |
65 | 65 | $this->getListeners( |
66 | 66 | $name, |
@@ -70,10 +70,10 @@ discard block |
||
70 | 70 | ), |
71 | 71 | $object |
72 | 72 | ); |
73 | - }else{ |
|
73 | + }else { |
|
74 | 74 | throw new \InvalidArgumentException('instance of \PEIP\INF\Event\Event must contain subject'); |
75 | 75 | } |
76 | - }else{ |
|
76 | + }else { |
|
77 | 77 | throw new \InvalidArgumentException('object must be instance of \PEIP\INF\Event\Event'); |
78 | 78 | } |
79 | 79 | } //put your code here |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | * @return |
91 | 91 | * @see EventBuilder |
92 | 92 | */ |
93 | - public function buildAndNotify($name, $object, array $headers = array(), $eventClass = false, $type = false){ |
|
94 | - if(!$this->hasListeners($name, ($object))){ |
|
93 | + public function buildAndNotify($name, $object, array $headers = array(), $eventClass = false, $type = false) { |
|
94 | + if (!$this->hasListeners($name, ($object))) { |
|
95 | 95 | return false; |
96 | 96 | } |
97 | 97 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * @param object $object object to check for listeners |
115 | 115 | * @return boolean |
116 | 116 | */ |
117 | - public function hasListeners($name, $object){ |
|
117 | + public function hasListeners($name, $object) { |
|
118 | 118 | return parent::hasListeners( |
119 | 119 | $name, |
120 | 120 | Reflection_Pool::getInstance($object) |
@@ -70,10 +70,10 @@ |
||
70 | 70 | ), |
71 | 71 | $object |
72 | 72 | ); |
73 | - }else{ |
|
73 | + } else{ |
|
74 | 74 | throw new \InvalidArgumentException('instance of \PEIP\INF\Event\Event must contain subject'); |
75 | 75 | } |
76 | - }else{ |
|
76 | + } else{ |
|
77 | 77 | throw new \InvalidArgumentException('object must be instance of \PEIP\INF\Event\Event'); |
78 | 78 | } |
79 | 79 | } //put your code here |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @access public |
24 | 24 | * @param string $name name of the event |
25 | 25 | * @param \PEIP\INF\Event\Event $object an event object |
26 | - * @return boolean |
|
26 | + * @return boolean|null |
|
27 | 27 | */ |
28 | 28 | public function notify($name, $object){ |
29 | 29 | if($object instanceof \PEIP\INF\Event\Event){ |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * @param array $headers headers of the event-object as key/value pairs |
54 | 54 | * @param string $eventClass event-class to create instances from |
55 | 55 | * @return |
56 | - * @see EventBuilder |
|
56 | + boolean|null @see EventBuilder |
|
57 | 57 | */ |
58 | 58 | public function buildAndNotify($name, $object, array $headers = array(), $eventClass = false, $type = false){ |
59 | 59 | if(!$this->hasListeners($name, ($object))){ |
@@ -11,7 +11,7 @@ |
||
11 | 11 | * |
12 | 12 | * @author timo |
13 | 13 | */ |
14 | -use PEIP\Util\Reflection; |
|
14 | +use PEIP\Util\Reflection; |
|
15 | 15 | use PEIP\Event\EventBuilder; |
16 | 16 | |
17 | 17 | class ClassEventDispatcher extends \PEIP\Dispatcher\ObjectEventDispatcher { |
@@ -43,7 +43,7 @@ |
||
43 | 43 | class_exists($className); |
44 | 44 | $res = ReflectionPool::getInstance($className) |
45 | 45 | ->implementsInterface($interfaceName); |
46 | - } catch (\Exception $e){ |
|
46 | + } catch (\Exception $e){ |
|
47 | 47 | $res = false; |
48 | 48 | } |
49 | 49 | return $res;; |
@@ -15,11 +15,11 @@ discard block |
||
15 | 15 | class Test { |
16 | 16 | |
17 | 17 | |
18 | - public static function assertClassHasConstructor($className){ |
|
19 | - return (boolean) ReflectionPool::getInstance($className)->getConstructor(); |
|
18 | + public static function assertClassHasConstructor($className) { |
|
19 | + return (boolean)ReflectionPool::getInstance($className)->getConstructor(); |
|
20 | 20 | } |
21 | 21 | |
22 | - public static function assertRequiredConstructorParameters($className, $parameters){ |
|
22 | + public static function assertRequiredConstructorParameters($className, $parameters) { |
|
23 | 23 | return (boolean) |
24 | 24 | !self::assertClassHasConstructor($className) || |
25 | 25 | count($parameters) >= ReflectionPool::getInstance($className) |
@@ -27,55 +27,55 @@ discard block |
||
27 | 27 | ->getNumberOfRequiredParameters(); |
28 | 28 | } |
29 | 29 | |
30 | - public static function assertInstanceOf($className, $object){ |
|
31 | - return (boolean) ReflectionPool::getInstance($className) |
|
30 | + public static function assertInstanceOf($className, $object) { |
|
31 | + return (boolean)ReflectionPool::getInstance($className) |
|
32 | 32 | ->isInstance($object); |
33 | 33 | } |
34 | 34 | |
35 | - public static function assertClassOrInterfaceExists($className){ |
|
36 | - return (boolean) class_exists($className) || interface_exists($className); |
|
35 | + public static function assertClassOrInterfaceExists($className) { |
|
36 | + return (boolean)class_exists($className) || interface_exists($className); |
|
37 | 37 | } |
38 | 38 | |
39 | - public static function assertImplements($className, $interfaceName){ |
|
39 | + public static function assertImplements($className, $interfaceName) { |
|
40 | 40 | $className = is_object($className) ? get_class($className) : $className; |
41 | - $res = false;//throw new \Exception(); |
|
41 | + $res = false; //throw new \Exception(); |
|
42 | 42 | try { |
43 | 43 | class_exists($className); |
44 | - $res = ReflectionPool::getInstance($className) |
|
44 | + $res = ReflectionPool::getInstance($className) |
|
45 | 45 | ->implementsInterface($interfaceName); |
46 | - } catch (\Exception $e){ |
|
46 | + } catch (\Exception $e) { |
|
47 | 47 | $res = false; |
48 | 48 | } |
49 | - return $res;; |
|
49 | + return $res; ; |
|
50 | 50 | } |
51 | 51 | |
52 | - public static function assertMessage($message){ |
|
52 | + public static function assertMessage($message) { |
|
53 | 53 | return self::assertImplements($message, '\PEIP\INF\Message\Message'); |
54 | 54 | } |
55 | 55 | |
56 | - public static function assertEvent($event){ |
|
56 | + public static function assertEvent($event) { |
|
57 | 57 | return self::assertImplements($event, '\PEIP\INF\Event\Event'); |
58 | 58 | } |
59 | 59 | |
60 | - public static function assertEventSubject($event){ |
|
60 | + public static function assertEventSubject($event) { |
|
61 | 61 | return self::assertImplements($event, '\PEIP\INF\Event\Event') |
62 | 62 | && $event->getSubject(); |
63 | 63 | } |
64 | 64 | |
65 | - public static function assertEventObjectSubject($event){ |
|
65 | + public static function assertEventObjectSubject($event) { |
|
66 | 66 | return self::assertEventSubject($event) |
67 | 67 | && is_object($event->getSubject()); |
68 | 68 | } |
69 | - public static function assertArrayAccess($var){ |
|
70 | - return (boolean) is_array($var) || $var instanceof \ArrayAccess; |
|
69 | + public static function assertArrayAccess($var) { |
|
70 | + return (boolean)is_array($var) || $var instanceof \ArrayAccess; |
|
71 | 71 | } |
72 | 72 | |
73 | - public static function assertHandler($var){ |
|
74 | - return (boolean) is_callable($var) || $var instanceof \PEIP\INF\Handler\Handler; |
|
73 | + public static function assertHandler($var) { |
|
74 | + return (boolean)is_callable($var) || $var instanceof \PEIP\INF\Handler\Handler; |
|
75 | 75 | } |
76 | 76 | |
77 | - public static function castType($var, $type){ |
|
78 | - switch($type){ |
|
77 | + public static function castType($var, $type) { |
|
78 | + switch ($type) { |
|
79 | 79 | case 'string': |
80 | 80 | $var = (string)$var; |
81 | 81 | break; |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | return $var; |
100 | 100 | } |
101 | 101 | |
102 | - public static function ensureArrayAccess($var){ |
|
103 | - if(!Test::assertArrayAccess($var)){ |
|
102 | + public static function ensureArrayAccess($var) { |
|
103 | + if (!Test::assertArrayAccess($var)) { |
|
104 | 104 | throw new \InvalidArgumentException( |
105 | 105 | 'Value is not an array nor an instance of ArrayAccess' |
106 | 106 | ); |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | } |
110 | 110 | |
111 | 111 | |
112 | - public static function ensureHandler($var){ |
|
113 | - if(!Test::assertHandler($var)){ |
|
112 | + public static function ensureHandler($var) { |
|
113 | + if (!Test::assertHandler($var)) { |
|
114 | 114 | throw new \InvalidArgumentException( |
115 | 115 | 'Value is not an callable nor an instance of \PEIP\INF\Handler\Handler' |
116 | 116 | ); |
@@ -118,8 +118,8 @@ discard block |
||
118 | 118 | return $var; |
119 | 119 | } |
120 | 120 | |
121 | - public static function ensureImplements($className, $interfaceName){ |
|
122 | - if(!Test::assertImplements($className, $interfaceName)){ |
|
121 | + public static function ensureImplements($className, $interfaceName) { |
|
122 | + if (!Test::assertImplements($className, $interfaceName)) { |
|
123 | 123 | throw new \InvalidArgumentException( |
124 | 124 | 'Class "'.$className.'" is not an instanceof "'.$interfaceName.'"' |
125 | 125 | ); |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | return $className; |
128 | 128 | } |
129 | 129 | |
130 | - public static function assertMethod($className, $methodname){ |
|
130 | + public static function assertMethod($className, $methodname) { |
|
131 | 131 | return ReflectionPool::getInstance($className)->hasMethod($methodname); |
132 | 132 | } |
133 | 133 |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @param $discardChannel |
34 | 34 | * @return |
35 | 35 | */ |
36 | - public function setDiscardChannel(\PEIP\INF\Channel\Channel $discardChannel){ |
|
36 | + public function setDiscardChannel(\PEIP\INF\Channel\Channel $discardChannel) { |
|
37 | 37 | $this->discardChannel = $discardChannel; |
38 | 38 | } |
39 | 39 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @access public |
43 | 43 | * @return |
44 | 44 | */ |
45 | - public function getDiscardChannel(){ |
|
45 | + public function getDiscardChannel() { |
|
46 | 46 | return $this->discardChannel; |
47 | 47 | } |
48 | 48 | |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | * @param $message |
53 | 53 | * @return |
54 | 54 | */ |
55 | - protected function discardMessage(\PEIP\INF\Message\Message $message){ |
|
56 | - if(isset($this->discardChannel)){ |
|
55 | + protected function discardMessage(\PEIP\INF\Message\Message $message) { |
|
56 | + if (isset($this->discardChannel)) { |
|
57 | 57 | $this->discardChannel->send($message); |
58 | 58 | } |
59 | 59 | } |
@@ -22,6 +22,6 @@ |
||
22 | 22 | |
23 | 23 | interface Singleton { |
24 | 24 | |
25 | - public static function getInstance (); |
|
25 | + public static function getInstance(); |
|
26 | 26 | |
27 | 27 | } |
@@ -46,19 +46,19 @@ |
||
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 |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | */ |
45 | 45 | |
46 | 46 | |
47 | -if($cafe){ |
|
47 | +if ($cafe) { |
|
48 | 48 | |
49 | 49 | for ($i = 1; $i <= 10; $i++) { |
50 | 50 | // create and place orders |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | var_dump($drinks); |
58 | 58 | } |
59 | 59 | |
60 | -}else{ |
|
60 | +}else { |
|
61 | 61 | throw new RuntimeException('Could not get CafeGateway'); |
62 | 62 | } |
63 | 63 |
@@ -57,7 +57,7 @@ |
||
57 | 57 | var_dump($drinks); |
58 | 58 | } |
59 | 59 | |
60 | -}else{ |
|
60 | +} else{ |
|
61 | 61 | throw new RuntimeException('Could not get CafeGateway'); |
62 | 62 | } |
63 | 63 |
@@ -2,11 +2,11 @@ |
||
2 | 2 | |
3 | 3 | require_once(dirname(__FILE__).'/../../../misc/bootstrap.php'); |
4 | 4 | |
5 | -foreach (glob(realpath(dirname(__FILE__)."/../lib/model/")."/*.php") as $filename){ |
|
5 | +foreach (glob(realpath(dirname(__FILE__)."/../lib/model/")."/*.php") as $filename) { |
|
6 | 6 | require_once $filename; |
7 | 7 | } |
8 | 8 | |
9 | -foreach (glob(realpath(dirname(__FILE__)."/../lib/messaging/")."/*.php") as $filename){ |
|
9 | +foreach (glob(realpath(dirname(__FILE__)."/../lib/messaging/")."/*.php") as $filename) { |
|
10 | 10 | require_once $filename; |
11 | 11 | } |
12 | 12 |
@@ -4,13 +4,13 @@ |
||
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 | } |
@@ -4,12 +4,12 @@ |
||
4 | 4 | |
5 | 5 | class CafeGateway extends SimpleMessagingGateway { |
6 | 6 | |
7 | - public function placeOrder(Order $order){ |
|
7 | + public function placeOrder(Order $order) { |
|
8 | 8 | echo "\nCafe: place order #".$order->getOrderNumber(); |
9 | 9 | $this->send($order); |
10 | 10 | } |
11 | 11 | |
12 | - public function receiveDelivery(){ |
|
12 | + public function receiveDelivery() { |
|
13 | 13 | return $this->receive(); |
14 | 14 | } |
15 | 15 |
@@ -4,38 +4,38 @@ |
||
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 | } |
@@ -9,30 +9,30 @@ |
||
9 | 9 | protected $orders = array(); |
10 | 10 | protected $preparedDrinks = array(); |
11 | 11 | |
12 | - public function __construct(Channel $inputChannel, Channel $outputChannel = NULL){ |
|
12 | + public function __construct(Channel $inputChannel, Channel $outputChannel = NULL) { |
|
13 | 13 | $this->setInputChannel($inputChannel); |
14 | - if(is_object($outputChannel)){ |
|
14 | + if (is_object($outputChannel)) { |
|
15 | 15 | $this->setOutputChannel($outputChannel); |
16 | 16 | } |
17 | 17 | $this->registerCommand('ADD_ORDER', array($this, 'receiveOrder')); |
18 | 18 | } |
19 | 19 | |
20 | - protected function doReply(Message $message){ |
|
20 | + protected function doReply(Message $message) { |
|
21 | 21 | $drink = $message->getContent(); |
22 | 22 | $nr = $drink->getOrderNumber(); |
23 | - if(!isset($this->preparedDrinks[$nr])){ |
|
23 | + if (!isset($this->preparedDrinks[$nr])) { |
|
24 | 24 | $this->preparedDrinks[$nr] = array(); |
25 | 25 | } |
26 | 26 | $this->preparedDrinks[$drink->getOrderNumber()][] = $drink; |
27 | - if(isset($this->orders[$nr]) |
|
28 | - && $this->orders[$nr]->getTotalCount() == count($this->preparedDrinks[$nr])){ |
|
27 | + if (isset($this->orders[$nr]) |
|
28 | + && $this->orders[$nr]->getTotalCount() == count($this->preparedDrinks[$nr])) { |
|
29 | 29 | $this->replyMessage($this->preparedDrinks[$nr]); |
30 | 30 | unset($this->preparedDrinks[$nr]); |
31 | 31 | echo PEIP_LINE_SEPARATOR.'DrinkAggregator : reply #'.$nr; |
32 | 32 | } |
33 | 33 | } |
34 | 34 | |
35 | - public function receiveOrder(Order $order){ |
|
35 | + public function receiveOrder(Order $order) { |
|
36 | 36 | echo PEIP_LINE_SEPARATOR.'DrinkAggregator: received Order'; |
37 | 37 | $this->orders[$order->getOrderNumber()] = $order; |
38 | 38 | } |