@@ -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 | } |
@@ -5,15 +5,15 @@ |
||
5 | 5 | |
6 | 6 | class OrderSplitter extends MessageSplitter { |
7 | 7 | |
8 | - public function split(Message $message){ |
|
8 | + public function split(Message $message) { |
|
9 | 9 | $order = $message->getContent(); |
10 | 10 | $orderItems = $order->getItems(); |
11 | 11 | $items = array(); |
12 | - foreach($orderItems as $item){ |
|
12 | + foreach ($orderItems as $item) { |
|
13 | 13 | $nr = $item['number']; |
14 | 14 | unset($item['number']); |
15 | 15 | $item['order'] = $order->getOrderNumber(); |
16 | - for($x = 0; $x < $nr; $x++){ |
|
16 | + for ($x = 0; $x < $nr; $x++) { |
|
17 | 17 | $items[] = $item; |
18 | 18 | } |
19 | 19 | } |
@@ -57,7 +57,7 @@ |
||
57 | 57 | |
58 | 58 | } |
59 | 59 | |
60 | -}else { |
|
60 | +} else { |
|
61 | 61 | throw new RuntimeException('Could not get CafeGateway'); |
62 | 62 | } |
63 | 63 |
@@ -207,11 +207,11 @@ |
||
207 | 207 | * @param $object |
208 | 208 | * @return boolean|null |
209 | 209 | */ |
210 | - protected static function doNotify(array $listeners, $subject){ |
|
211 | - foreach($listeners as $listener){ |
|
212 | - if($listener instanceof \PEIP\INF\Handler\Handler){ |
|
210 | + protected static function doNotify(array $listeners, $subject) { |
|
211 | + foreach ($listeners as $listener) { |
|
212 | + if ($listener instanceof \PEIP\INF\Handler\Handler) { |
|
213 | 213 | $listener->handle($subject); |
214 | - }elseif(is_callable($listener)){ |
|
214 | + }elseif (is_callable($listener)) { |
|
215 | 215 | call_user_func($listener, $subject); |
216 | 216 | } |
217 | 217 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | $listners = $this->doGetListeners(); |
105 | 105 | if (!$this->hadListeners($name, $object)) { |
106 | 106 | $res = false; |
107 | - }else { |
|
107 | + } else { |
|
108 | 108 | $listners = $this->doGetListeners(); |
109 | 109 | $res = (boolean)count($listners[$object][$name]); |
110 | 110 | } |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | foreach($listeners as $listener){ |
212 | 212 | if($listener instanceof \PEIP\INF\Handler\Handler){ |
213 | 213 | $listener->handle($subject); |
214 | - }elseif(is_callable($listener)){ |
|
214 | + } elseif(is_callable($listener)){ |
|
215 | 215 | call_user_func($listener, $subject); |
216 | 216 | } |
217 | 217 | } |
@@ -43,18 +43,18 @@ |
||
43 | 43 | } |
44 | 44 | } //put your code here |
45 | 45 | |
46 | - /** |
|
47 | - * Creates an event-object with given object as content/subject and notifies |
|
48 | - * all registers listeners of the event. |
|
49 | - * |
|
50 | - * @access public |
|
51 | - * @param string $name name of the event |
|
52 | - * @param object $object the subject of the event |
|
53 | - * @param array $headers headers of the event-object as key/value pairs |
|
54 | - * @param string $eventClass event-class to create instances from |
|
55 | - * @return |
|
46 | + /** |
|
47 | + * Creates an event-object with given object as content/subject and notifies |
|
48 | + * all registers listeners of the event. |
|
49 | + * |
|
50 | + * @access public |
|
51 | + * @param string $name name of the event |
|
52 | + * @param object $object the subject of the event |
|
53 | + * @param array $headers headers of the event-object as key/value pairs |
|
54 | + * @param string $eventClass event-class to create instances from |
|
55 | + * @return |
|
56 | 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))) { |
60 | 60 | return false; |
@@ -35,10 +35,10 @@ |
||
35 | 35 | ), |
36 | 36 | $object->getContent() |
37 | 37 | ); |
38 | - }else{ |
|
38 | + }else { |
|
39 | 39 | throw new \InvalidArgumentException('instance of \PEIP\INF\Event\Event must contain subject'); |
40 | 40 | } |
41 | - }else{ |
|
41 | + }else { |
|
42 | 42 | throw new \InvalidArgumentException('object must be instance of \PEIP\INF\Event\Event'); |
43 | 43 | } |
44 | 44 | } //put your code here |
@@ -46,10 +46,10 @@ |
||
46 | 46 | if ($this->hasListeners($name, $object->getContent())) { |
47 | 47 | return self::doNotify($this->getListeners($name, $object->getContent()), $object); |
48 | 48 | } |
49 | - }else { |
|
49 | + } else { |
|
50 | 50 | throw new \InvalidArgumentException('instance of \PEIP\INF\Event\Event must contain subject'); |
51 | 51 | } |
52 | - }else { |
|
52 | + } else { |
|
53 | 53 | throw new \InvalidArgumentException('object must be instance of \PEIP\INF\Event\Event'); |
54 | 54 | } |
55 | 55 | } |
@@ -22,7 +22,7 @@ |
||
22 | 22 | $name = is_object($name) ? get_class($name) : (string)$name; |
23 | 23 | if (Test::assertClassOrInterfaceExists($name)) { |
24 | 24 | parent::connect($name, $listener); |
25 | - }else { |
|
25 | + } else { |
|
26 | 26 | throw new \InvalidArgumentException($name." is not an Class nor Interface"); |
27 | 27 | } |
28 | 28 | } |
@@ -24,9 +24,9 @@ |
||
24 | 24 | |
25 | 25 | interface ListDispatcher extends \PEIP\INF\Dispatcher\Dispatcher { |
26 | 26 | |
27 | - public function connect( $handler); |
|
27 | + public function connect($handler); |
|
28 | 28 | |
29 | - public function disconnect( $handler); |
|
29 | + public function disconnect($handler); |
|
30 | 30 | |
31 | 31 | public function hasListeners(); |
32 | 32 |
@@ -26,11 +26,11 @@ |
||
26 | 26 | |
27 | 27 | public function disconnect($name, \PEIP\INF\Message\MessageHandler $handler); |
28 | 28 | |
29 | - public function notify( $event); |
|
29 | + public function notify($event); |
|
30 | 30 | |
31 | - public function notifyUntil( $event); |
|
31 | + public function notifyUntil($event); |
|
32 | 32 | |
33 | - public function filter( $event, $value); |
|
33 | + public function filter($event, $value); |
|
34 | 34 | |
35 | 35 | public function hasListeners($name); |
36 | 36 |