@@ -6,9 +6,9 @@ |
||
6 | 6 | class DrinkRouter |
7 | 7 | extends Router { |
8 | 8 | |
9 | - protected function selectChannels(Message $message){ |
|
9 | + protected function selectChannels(Message $message) { |
|
10 | 10 | $order = $message->getContent(); |
11 | - $channelName = $order['iced'] ? 'coldDrinks' : 'hotDrinks'; |
|
11 | + $channelName = $order['iced'] ? 'coldDrinks' : 'hotDrinks'; |
|
12 | 12 | echo PEIP_LINE_SEPARATOR."DrinkRouter: routed to channel: $channelName"; |
13 | 13 | return $channelName; |
14 | 14 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @param mixed $value the value to store |
35 | 35 | * @return |
36 | 36 | */ |
37 | - public function setValue($key, $value){ |
|
37 | + public function setValue($key, $value) { |
|
38 | 38 | return $this->offsetSet($key, $value); |
39 | 39 | } |
40 | 40 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @param mixed $key the key to return value for |
46 | 46 | * @return mixed the value for the given key |
47 | 47 | */ |
48 | - public function getValue($key){ |
|
48 | + public function getValue($key) { |
|
49 | 49 | return $this->offsetGet($key, $value); |
50 | 50 | } |
51 | 51 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @param mixed $key the key to unset value for |
57 | 57 | * @return |
58 | 58 | */ |
59 | - public function deleteValue($key){ |
|
59 | + public function deleteValue($key) { |
|
60 | 60 | return $this->offsetUnset($key); |
61 | 61 | } |
62 | 62 | |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @param mixed $key the key to look for a value |
68 | 68 | * @return boolean wether a value is stored for the key |
69 | 69 | */ |
70 | - public function hasValue($key){ |
|
70 | + public function hasValue($key) { |
|
71 | 71 | return $this->offsetExists($key); |
72 | 72 | } |
73 | 73 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @param array $values key/value pairs to store |
79 | 79 | * @return |
80 | 80 | */ |
81 | - public function setValues(array $values){ |
|
81 | + public function setValues(array $values) { |
|
82 | 82 | $this->values = $values; |
83 | 83 | } |
84 | 84 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @access public |
89 | 89 | * @return array stored key/value pairs |
90 | 90 | */ |
91 | - public function getValues(){ |
|
91 | + public function getValues() { |
|
92 | 92 | return $this->values; |
93 | 93 | } |
94 | 94 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * @param $values |
101 | 101 | * @return |
102 | 102 | */ |
103 | - public function addValues(array $values){ |
|
103 | + public function addValues(array $values) { |
|
104 | 104 | array_merge($this->values, $values); |
105 | 105 | } |
106 | 106 | } |
107 | 107 | \ No newline at end of file |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | * @param string $eventName name of the event to listen to |
39 | 39 | * @param \PEIP\INF\Event\Connectable $connectable instance of \PEIP\INF\Event\Connectable to listen to |
40 | 40 | */ |
41 | - protected function doListen($eventName, \PEIP\INF\Event\Connectable $connectable){ |
|
42 | - if(!$connectable->hasListener($eventName, $this)){ |
|
41 | + protected function doListen($eventName, \PEIP\INF\Event\Connectable $connectable) { |
|
42 | + if (!$connectable->hasListener($eventName, $this)) { |
|
43 | 43 | $connectable->connect($eventName, $this); |
44 | 44 | $this->connections[spl_object_hash($connectable)] = $connectable; |
45 | 45 | } |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | * @param string $eventName name of the event to unlisten |
53 | 53 | * @param \PEIP\INF\Event\Connectable $connectable instance of \PEIP\INF\Event\Connectable to unlisten to |
54 | 54 | */ |
55 | - protected function doUnlisten($eventName, \PEIP\INF\Event\Connectable $connectable){ |
|
56 | - if(!$connectable->hasListener($eventName, $this)){ |
|
55 | + protected function doUnlisten($eventName, \PEIP\INF\Event\Connectable $connectable) { |
|
56 | + if (!$connectable->hasListener($eventName, $this)) { |
|
57 | 57 | $connectable->disconnect($eventName, $this); |
58 | 58 | unset($this->connections[spl_object_hash($connectable)]); |
59 | 59 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @access public |
66 | 66 | * @return array array of \PEIP\INF\Event\Connectable instances |
67 | 67 | */ |
68 | - public function doGetConnected(){ |
|
68 | + public function doGetConnected() { |
|
69 | 69 | return array_values($this->connections); |
70 | 70 | } |
71 | 71 |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | * @param \PEIP\INF\Channel\Channel $outputChannel the outputs-channel |
36 | 36 | * @return |
37 | 37 | */ |
38 | - public function __construct(\PEIP\INF\Channel\Channel $inputChannel, \PEIP\INF\Channel\Channel $outputChannel = NULL){ |
|
38 | + public function __construct(\PEIP\INF\Channel\Channel $inputChannel, \PEIP\INF\Channel\Channel $outputChannel = NULL) { |
|
39 | 39 | $this->setInputChannel($inputChannel); |
40 | - if(is_object($outputChannel)){ |
|
40 | + if (is_object($outputChannel)) { |
|
41 | 41 | $this->setOutputChannel($outputChannel); |
42 | 42 | } |
43 | 43 | } |
@@ -49,13 +49,13 @@ discard block |
||
49 | 49 | * @param \PEIP\INF\Message\Message $message message to split |
50 | 50 | * @return |
51 | 51 | */ |
52 | - public function doReply(\PEIP\INF\Message\Message $message){ |
|
52 | + public function doReply(\PEIP\INF\Message\Message $message) { |
|
53 | 53 | $res = $this->split($message); |
54 | - if(is_array($res)){ |
|
55 | - foreach($res as $msg){ |
|
54 | + if (is_array($res)) { |
|
55 | + foreach ($res as $msg) { |
|
56 | 56 | $this->replyMessage($msg); |
57 | 57 | } |
58 | - }else{ |
|
58 | + }else { |
|
59 | 59 | $this->replyMessage($res); |
60 | 60 | } |
61 | 61 | } |
@@ -33,7 +33,7 @@ |
||
33 | 33 | * @param $outputChannel |
34 | 34 | * @return |
35 | 35 | */ |
36 | - public function __construct($eventName, \PEIP\INF\Channel\Channel $inputChannel, \PEIP\INF\Channel\Channel $outputChannel){ |
|
36 | + public function __construct($eventName, \PEIP\INF\Channel\Channel $inputChannel, \PEIP\INF\Channel\Channel $outputChannel) { |
|
37 | 37 | $this->setEventName($eventName); |
38 | 38 | $this->setInputChannel($inputChannel); |
39 | 39 | $this->setOutputChannel($outputChannel); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @param $type |
48 | 48 | * @return |
49 | 49 | */ |
50 | - public function __construct($type){ |
|
50 | + public function __construct($type) { |
|
51 | 51 | $this->type = $type; |
52 | 52 | } |
53 | 53 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @param $message |
58 | 58 | * @return |
59 | 59 | */ |
60 | - public function acceptMessage(\PEIP\INF\Message\Message $message){ |
|
60 | + public function acceptMessage(\PEIP\INF\Message\Message $message) { |
|
61 | 61 | return call_user_func(self::$types[$this->type], $message->getContent()); |
62 | 62 | } |
63 | 63 |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @param Callable|PEIP\INF\Handler\Handler $listener |
41 | 41 | * @return void |
42 | 42 | */ |
43 | - public function connect($listener){ |
|
43 | + public function connect($listener) { |
|
44 | 44 | Test::ensureHandler($listener); |
45 | 45 | $this->listeners[] = $listener; |
46 | 46 | } |
@@ -52,10 +52,10 @@ discard block |
||
52 | 52 | * @param Callable|PEIP\INF\Handler\Handler $listener |
53 | 53 | * @return void |
54 | 54 | */ |
55 | - public function disconnect($listener){ |
|
55 | + public function disconnect($listener) { |
|
56 | 56 | Test::ensureHandler($listener); |
57 | - foreach ($this->listeners as $i => $callable){ |
|
58 | - if ($listener === $callable){ |
|
57 | + foreach ($this->listeners as $i => $callable) { |
|
58 | + if ($listener === $callable) { |
|
59 | 59 | unset($this->listeners[$i]); |
60 | 60 | } |
61 | 61 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @param Callable|PEIP\INF\Handler\Handler $listener |
69 | 69 | * @return void |
70 | 70 | */ |
71 | - public function disconnectAll(){ |
|
71 | + public function disconnectAll() { |
|
72 | 72 | $this->listeners = array(); |
73 | 73 | } |
74 | 74 | |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | * @access public |
79 | 79 | * @return boolean wether any listeners are registered |
80 | 80 | */ |
81 | - public function hasListeners(){ |
|
82 | - return (boolean) count($this->listeners); |
|
81 | + public function hasListeners() { |
|
82 | + return (boolean)count($this->listeners); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | * @param mixed $subject the subject |
90 | 90 | * @return void |
91 | 91 | */ |
92 | - public function notify($subject){ |
|
92 | + public function notify($subject) { |
|
93 | 93 | $res = NULL; |
94 | - if($this->hasListeners()){ |
|
94 | + if ($this->hasListeners()) { |
|
95 | 95 | $res = self::doNotify($this->getListeners(), $subject); |
96 | 96 | } |
97 | 97 | return $res; |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | * @param mixed $subject the subject |
105 | 105 | * @return \PEIP\INF\Handler\Handler the listener which returned a boolean true value |
106 | 106 | */ |
107 | - public function notifyUntil($subject){ |
|
108 | - if($this->hasListeners()){ |
|
107 | + public function notifyUntil($subject) { |
|
108 | + if ($this->hasListeners()) { |
|
109 | 109 | $res = self::doNotifyUntil($this->getListeners(), $subject); |
110 | 110 | } |
111 | 111 | return $res; |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * @access public |
118 | 118 | * @return array the listeners |
119 | 119 | */ |
120 | - public function getListeners(){ |
|
120 | + public function getListeners() { |
|
121 | 121 | return $this->listeners; |
122 | 122 | } |
123 | 123 |
@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | * @return array array with interface/class info for the class |
31 | 31 | */ |
32 | 32 | |
33 | - public static function getImplementedClassesAndInterfaces($class, $store = true){ |
|
33 | + public static function getImplementedClassesAndInterfaces($class, $store = true) { |
|
34 | 34 | $class = is_object($class) ? get_class($class) : (string)$class; |
35 | - if(isset(self::$classInfo[$class])){ |
|
35 | + if (isset(self::$classInfo[$class])) { |
|
36 | 36 | return self::$classInfo[$class]; |
37 | 37 | } |
38 | 38 | $cls = ReflectionPool::getInstance($class); |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | $classInfo = (array)$cls->getInterfaceNames(); |
41 | 41 | $classInfo[] = $cls->getName(); |
42 | 42 | // get names of parent-classes |
43 | - while($cls = $cls->getParentClass()){ |
|
43 | + while ($cls = $cls->getParentClass()) { |
|
44 | 44 | $classInfo[] = $cls->getName(); |
45 | 45 | } |
46 | 46 |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @param object $config configuration object for the pollable channel. |
43 | 43 | * @return \PEIP\INF\Channel\Channel the created pollable channel instance |
44 | 44 | */ |
45 | - public function createChannel($config){ |
|
45 | + public function createChannel($config) { |
|
46 | 46 | return $this->doCreateChannel($config, '\PEIP\Channel\PollableChannel'); |
47 | 47 | } |
48 | 48 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @param object $config configuration object for the subscribable channel. |
55 | 55 | * @return \PEIP\INF\Channel\Channel the created subscribable channel instance |
56 | 56 | */ |
57 | - public function createSubscribableChannel($config){ |
|
57 | + public function createSubscribableChannel($config) { |
|
58 | 58 | return $this->doCreateChannel($config, '\PEIP\Channel\PublishSubscribeChannel'); |
59 | 59 | } |
60 | 60 | |
@@ -67,9 +67,9 @@ discard block |
||
67 | 67 | * @param $additionalArguments additional arguments for the channel constructor (without first arg = id) |
68 | 68 | * @return \PEIP\INF\Channel\Channel the created channel instance |
69 | 69 | */ |
70 | - public function doCreateChannel($config, $defaultChannelClass, array $additionalArguments = array()){ |
|
70 | + public function doCreateChannel($config, $defaultChannelClass, array $additionalArguments = array()) { |
|
71 | 71 | $id = (string)$config['id']; |
72 | - if($id != ''){ |
|
72 | + if ($id != '') { |
|
73 | 73 | array_unshift($additionalArguments, $id); |
74 | 74 | $channel = $this->buildAndModify($config, $additionalArguments, $defaultChannelClass); |
75 | 75 | //$this->channelRegistry->register($channel); |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * @param string $defaultClass the class to use if none is set in config. |
88 | 88 | * @return object the gateway instance |
89 | 89 | */ |
90 | - public function createGateway($config, $defaultClass = false){ |
|
90 | + public function createGateway($config, $defaultClass = false) { |
|
91 | 91 | $args = array( |
92 | 92 | $this->getRequestChannel($config), |
93 | 93 | $this->getReplyChannel($config) |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * @param string $defaultClass the class to use if none is set in config. |
112 | 112 | * @return object the router instance |
113 | 113 | */ |
114 | - public function createRouter($config, $defaultClass = false){ |
|
114 | + public function createRouter($config, $defaultClass = false) { |
|
115 | 115 | $resolver = $config['channel_resolver'] ? (string)$config['channel_resolver'] : $this->channelRegistry; |
116 | 116 | return $this->buildAndModify($config, array( |
117 | 117 | $resolver, |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @param object $config configuration object for the splitter. |
129 | 129 | * @return object the splitter instance |
130 | 130 | */ |
131 | - public function createSplitter($config){ |
|
131 | + public function createSplitter($config) { |
|
132 | 132 | return $this->createReplyMessageHandler($config); |
133 | 133 | } |
134 | 134 | |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * @param object $config configuration object for the transformer. |
142 | 142 | * @return object the transformer instance |
143 | 143 | */ |
144 | - public function createTransformer($config){ |
|
144 | + public function createTransformer($config) { |
|
145 | 145 | return $this->createReplyMessageHandler($config); |
146 | 146 | } |
147 | 147 | |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | * @param object $config configuration object for the aggregator. |
155 | 155 | * @return object the aggregator instance |
156 | 156 | */ |
157 | - public function createAggregator($config){ |
|
157 | + public function createAggregator($config) { |
|
158 | 158 | return $this->createReplyMessageHandler($config); |
159 | 159 | } |
160 | 160 | |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | * @param object $config configuration object for the wiretap. |
168 | 168 | * @return object the wiretap instance |
169 | 169 | */ |
170 | - public function createWiretap($config){ |
|
170 | + public function createWiretap($config) { |
|
171 | 171 | return $this->createReplyMessageHandler($config, '\PEIP\Listener\Wiretap'); |
172 | 172 | } |
173 | 173 | |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * @param string $defaultClass the class to use if none is set in config. |
181 | 181 | * @return object the reply-message-handler instance |
182 | 182 | */ |
183 | - public function createReplyMessageHandler($config, $defaultClass = false){ |
|
183 | + public function createReplyMessageHandler($config, $defaultClass = false) { |
|
184 | 184 | return $this->buildAndModify($config, $this->getReplyHandlerArguments($config), $defaultClass); |
185 | 185 | } |
186 | 186 | |
@@ -193,12 +193,12 @@ discard block |
||
193 | 193 | * @param string $defaultClass the class to use if none is set in config. |
194 | 194 | * @return object the service-activator instance |
195 | 195 | */ |
196 | - public function createServiceActivator($config, $defaultClass = false){ |
|
196 | + public function createServiceActivator($config, $defaultClass = false) { |
|
197 | 197 | $method = (string)$config['method']; |
198 | 198 | $service = $this->context->getServiceProvider()->provideService((string)$config['ref']); |
199 | - if($method && $service){ |
|
199 | + if ($method && $service) { |
|
200 | 200 | $args = $this->getReplyHandlerArguments($config); |
201 | - array_unshift($args,array( |
|
201 | + array_unshift($args, array( |
|
202 | 202 | $service, |
203 | 203 | $method |
204 | 204 | )); |
@@ -215,12 +215,12 @@ discard block |
||
215 | 215 | * @param object $config configuration object to create arguments from. |
216 | 216 | * @return mixed build arguments |
217 | 217 | */ |
218 | - protected function getReplyHandlerArguments($config){ |
|
218 | + protected function getReplyHandlerArguments($config) { |
|
219 | 219 | $args = array( |
220 | 220 | $this->doGetChannel('input', $config), |
221 | 221 | $this->doGetChannel('output', $config) |
222 | 222 | ); |
223 | - if($args[0] == NULL){ |
|
223 | + if ($args[0] == NULL) { |
|
224 | 224 | throw new \RuntimeException('Could not receive input channel.'); |
225 | 225 | } |
226 | 226 | return $args; |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | * @param object $config configuration object to return request-channel from. |
236 | 236 | * @return \PEIP\INF\Channel\Channel request-channel |
237 | 237 | */ |
238 | - protected function getRequestChannel($config){ |
|
238 | + protected function getRequestChannel($config) { |
|
239 | 239 | return $this->doGetChannel('request', $config); |
240 | 240 | } |
241 | 241 | |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | * @param object $config configuration object to return reply-channel from. |
249 | 249 | * @return \PEIP\INF\Channel\Channel reply-channel |
250 | 250 | */ |
251 | - protected function getReplyChannel($config){ |
|
251 | + protected function getReplyChannel($config) { |
|
252 | 252 | return $this->doGetChannel('reply', $config); |
253 | 253 | } |
254 | 254 | |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | * @param object $config configuration object to return channel from. |
262 | 262 | * @return \PEIP\INF\Channel\Channel reply-channel |
263 | 263 | */ |
264 | - public function doGetChannel($type, $config){ |
|
264 | + public function doGetChannel($type, $config) { |
|
265 | 265 | $channelName = isset($config[$type."_channel"]) |
266 | 266 | ? $config[$type."_channel"] |
267 | 267 | : $config["default_".$type."_channel"]; |