@@ -38,12 +38,12 @@ discard block |
||
38 | 38 | * @param \PEIP\INF\Message\Message $message message to handle/reply for |
39 | 39 | * @return |
40 | 40 | */ |
41 | - public function doReply(\PEIP\INF\Message\Message $message){ |
|
41 | + public function doReply(\PEIP\INF\Message\Message $message) { |
|
42 | 42 | $res = $this->callService($message); |
43 | 43 | $out = (bool)$message->hasHeader('REPLY_CHANNEL') |
44 | 44 | ? $message->getHeader('REPLY_CHANNEL') |
45 | 45 | : $this->outputChannel; |
46 | - if($out){ |
|
46 | + if ($out) { |
|
47 | 47 | $this->replyMessage($res, $res); |
48 | 48 | } |
49 | 49 | } |
@@ -56,12 +56,12 @@ discard block |
||
56 | 56 | * @param \PEIP\INF\Message\Message $message message to call the service with it�s content/payload |
57 | 57 | * @return mixed result of calling the registered service callable with message content/payload |
58 | 58 | */ |
59 | - protected function callService(\PEIP\INF\Message\Message $message){ |
|
59 | + protected function callService(\PEIP\INF\Message\Message $message) { |
|
60 | 60 | $res = NULL; |
61 | - if(is_callable($this->serviceCallable)){ |
|
61 | + if (is_callable($this->serviceCallable)) { |
|
62 | 62 | $res = call_user_func($this->serviceCallable, $message->getContent()); |
63 | - }else{ |
|
64 | - if(is_object($this->serviceCallable) && method_exists($this->serviceCallable, 'handle')){ |
|
63 | + }else { |
|
64 | + if (is_object($this->serviceCallable) && method_exists($this->serviceCallable, 'handle')) { |
|
65 | 65 | $res = $this->serviceCallable->handle($message->getContent()); |
66 | 66 | } |
67 | 67 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @param \PEIP\INF\Channel\Channel $outputChannel the output-channel |
43 | 43 | * @return \PEIP\ABS\Handler\MessageHandler $this; |
44 | 44 | */ |
45 | - public function setOutputChannel(\PEIP\INF\Channel\Channel $outputChannel){ |
|
45 | + public function setOutputChannel(\PEIP\INF\Channel\Channel $outputChannel) { |
|
46 | 46 | $this->doSetOutputChannel($outputChannel); |
47 | 47 | return $this; |
48 | 48 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @param \PEIP\INF\Channel\Channel $inputChannel the output-channel to connect the handler to |
55 | 55 | * @return |
56 | 56 | */ |
57 | - protected function doSetOutputChannel(\PEIP\INF\Channel\Channel $outputChannel){ |
|
57 | + protected function doSetOutputChannel(\PEIP\INF\Channel\Channel $outputChannel) { |
|
58 | 58 | $this->outputChannel = $outputChannel; |
59 | 59 | } |
60 | 60 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * @access public |
65 | 65 | * @return \PEIP\INF\Channel\Channel output-channel for this handler |
66 | 66 | */ |
67 | - public function getOutputChannel(){ |
|
67 | + public function getOutputChannel() { |
|
68 | 68 | return $this->outputChannel; |
69 | 69 | } |
70 | 70 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @param \PEIP\INF\Message\Message $message the message to resolve output-channel for |
79 | 79 | * @return \PEIP\INF\Channel\Channel the output-channel for the message |
80 | 80 | */ |
81 | - protected function doGetOutputChannel(\PEIP\INF\Message\Message $message){ |
|
81 | + protected function doGetOutputChannel(\PEIP\INF\Message\Message $message) { |
|
82 | 82 | $replyChannel = $this->resolveReplyChannel($message); |
83 | 83 | return $replyChannel ? $replyChannel : $this->getOutputChannel(); |
84 | 84 | } |
@@ -92,9 +92,9 @@ discard block |
||
92 | 92 | * @param \PEIP\INF\Message\Message $message |
93 | 93 | * @return \PEIP\INF\Channel\Channel the reply-channel if found |
94 | 94 | */ |
95 | - protected function resolveReplyChannel(\PEIP\INF\Message\Message $message){ |
|
96 | - foreach($this->replyChannelHeaders as $header){ |
|
97 | - if($message->hasHeader($header)){ |
|
95 | + protected function resolveReplyChannel(\PEIP\INF\Message\Message $message) { |
|
96 | + foreach ($this->replyChannelHeaders as $header) { |
|
97 | + if ($message->hasHeader($header)) { |
|
98 | 98 | return $message->getHeader($header); |
99 | 99 | } |
100 | 100 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * @access protected |
112 | 112 | * @param mixed $content \PEIP\INF\Message\Message or content/payload for new message |
113 | 113 | */ |
114 | - protected function replyMessage($content){ |
|
114 | + protected function replyMessage($content) { |
|
115 | 115 | $message = $this->ensureMessage($content); |
116 | 116 | $this->doGetOutputChannel($message)->send($message); |
117 | 117 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | * @param mixed $message \PEIP\INF\Message\Message or content/payload for new message |
126 | 126 | * @return \PEIP\INF\Message\Message |
127 | 127 | */ |
128 | - protected function ensureMessage($message){ |
|
128 | + protected function ensureMessage($message) { |
|
129 | 129 | return ($message instanceof \PEIP\INF\Message\Message) ? $message : $this->buildMessage($message); |
130 | 130 | } |
131 | 131 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * @return \PEIP\INF\Message\Message |
139 | 139 | * @see MessageBuilder |
140 | 140 | */ |
141 | - protected function buildMessage($content){ |
|
141 | + protected function buildMessage($content) { |
|
142 | 142 | return $this->getMessageBuilder()->setContent($content)->build(); |
143 | 143 | } |
144 | 144 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * @access protected |
150 | 150 | * @return MessageBuilder builder for the registered message class |
151 | 151 | */ |
152 | - protected function getMessageBuilder(){ |
|
152 | + protected function getMessageBuilder() { |
|
153 | 153 | return isset($this->messageBuilder) && ($this->messageBuilder->getMessageClass() == $this->getMessageClass()) |
154 | 154 | ? $this->messageBuilder |
155 | 155 | : $this->messageBuilder = MessageBuilder::getInstance($this->messageClass); |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | * @param string $messageClass name of the message-class to create reply-messages from. |
163 | 163 | * @return PEIP\ABS\Handler\ReplyProducingMessageHandler $this |
164 | 164 | */ |
165 | - public function setMessageClass($messageClass){ |
|
165 | + public function setMessageClass($messageClass) { |
|
166 | 166 | $this->messageClass = $messageClass; |
167 | 167 | return $this; |
168 | 168 | } |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * @access public |
174 | 174 | * @return string name of the message-class to create reply-messages from. |
175 | 175 | */ |
176 | - public function getMessageClass(){ |
|
176 | + public function getMessageClass() { |
|
177 | 177 | return $this->messageClass; |
178 | 178 | } |
179 | 179 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | * @param string $headerName name of a message-header to look for a reply-channel |
185 | 185 | * @return void |
186 | 186 | */ |
187 | - public function addReplyChannelHeader($headerName){ |
|
187 | + public function addReplyChannelHeader($headerName) { |
|
188 | 188 | $this->replyChannelHeaders[] = $headerName; |
189 | 189 | } |
190 | 190 | |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * @param array $headerNames array of message-header names to look for a reply-channel |
196 | 196 | * @return PEIP\ABS\Handler\ReplyProducingMessageHandler $this |
197 | 197 | */ |
198 | - public function setReplyChannelHeaders(array $headerNames){ |
|
198 | + public function setReplyChannelHeaders(array $headerNames) { |
|
199 | 199 | $this->replyChannelHeaders = $headerNames; |
200 | 200 | return $this; |
201 | 201 | } |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | * @access public |
207 | 207 | * @return array array of message-header names to look for a reply-channel |
208 | 208 | */ |
209 | - public function getReplyChannelHeaders(){ |
|
209 | + public function getReplyChannelHeaders() { |
|
210 | 210 | return $this->replyChannelHeaders; |
211 | 211 | } |
212 | 212 | |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * @param \PEIP\INF\Message\Message $message |
221 | 221 | * @return |
222 | 222 | */ |
223 | - protected function doHandle(\PEIP\INF\Message\Message $message){ |
|
223 | + protected function doHandle(\PEIP\INF\Message\Message $message) { |
|
224 | 224 | return $this->doReply($message); |
225 | 225 | } |
226 | 226 |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @param object $message the message to handle |
43 | 43 | * @return |
44 | 44 | */ |
45 | - public function handle($message){ |
|
45 | + public function handle($message) { |
|
46 | 46 | $this->doHandle($this->getMessageFromObject($message)); |
47 | 47 | } |
48 | 48 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @param \PEIP\INF\Channel\Channel $inputChannel the input-channel |
57 | 57 | * @return PEIP\ABS\Handler\MessageHandler $this; |
58 | 58 | */ |
59 | - public function setInputChannel(\PEIP\INF\Channel\Channel $inputChannel){ |
|
59 | + public function setInputChannel(\PEIP\INF\Channel\Channel $inputChannel) { |
|
60 | 60 | $this->doSetInputChannel($inputChannel); |
61 | 61 | return $this; |
62 | 62 | } |
@@ -73,24 +73,24 @@ discard block |
||
73 | 73 | * @param \PEIP\INF\Channel\Channel $inputChannel the input-channel to connect the handler to |
74 | 74 | * @return |
75 | 75 | */ |
76 | - protected function doSetInputChannel(\PEIP\INF\Channel\Channel $inputChannel){ |
|
76 | + protected function doSetInputChannel(\PEIP\INF\Channel\Channel $inputChannel) { |
|
77 | 77 | $this->inputChannel = $inputChannel; |
78 | - if($this->inputChannel instanceof \PEIP\INF\Channel\SubscribableChannel){ |
|
78 | + if ($this->inputChannel instanceof \PEIP\INF\Channel\SubscribableChannel) { |
|
79 | 79 | $this->inputChannel->subscribe($this); |
80 | - }else{ |
|
80 | + }else { |
|
81 | 81 | $this->unwrapEvents = true; |
82 | 82 | $this->inputChannel->connect('postSend', $this); |
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
86 | - protected function getMessageFromObject($object){ |
|
86 | + protected function getMessageFromObject($object) { |
|
87 | 87 | $content = $object->getContent(); |
88 | - if($this->unwrapEvents |
|
88 | + if ($this->unwrapEvents |
|
89 | 89 | && $object instanceof \PEIP\INF\Event\Event |
90 | 90 | && $object->getName() == 'postSend' |
91 | 91 | && $object->hasHeader(Pipe::HEADER_MESSAGE) |
92 | 92 | && $content instanceof \PEIP\INF\Channel\PollableChannel |
93 | - ){ |
|
93 | + ) { |
|
94 | 94 | $object = $content->receive(); |
95 | 95 | } |
96 | 96 | if (!($object instanceof \PEIP\INF\Message\Message)) { |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * @access public |
107 | 107 | * @return \PEIP\INF\Channel\Channel input-channel for this handler |
108 | 108 | */ |
109 | - public function getInputChannel(){ |
|
109 | + public function getInputChannel() { |
|
110 | 110 | return $this->inputChannel; |
111 | 111 | } |
112 | 112 |
@@ -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 | } |
@@ -44,9 +44,9 @@ discard block |
||
44 | 44 | * @param Callable|PEIP\INF\Handler\Handler $listener listener to connect |
45 | 45 | * @return |
46 | 46 | */ |
47 | - public function connect($name, $listener){ |
|
47 | + public function connect($name, $listener) { |
|
48 | 48 | Test::ensureHandler($listener); |
49 | - if (!$this->hasListeners($name)){ |
|
49 | + if (!$this->hasListeners($name)) { |
|
50 | 50 | $this->listeners[$name] = array(); |
51 | 51 | } |
52 | 52 | $this->listeners[$name][] = $listener; |
@@ -61,13 +61,13 @@ discard block |
||
61 | 61 | * @param Callable|PEIP\INF\Handler\Handler $listener listener to connect |
62 | 62 | * @return |
63 | 63 | */ |
64 | - public function disconnect($name, $listener){ |
|
65 | - if (!$this->hasListeners($name)){ |
|
64 | + public function disconnect($name, $listener) { |
|
65 | + if (!$this->hasListeners($name)) { |
|
66 | 66 | return false; |
67 | 67 | } |
68 | 68 | $res = false; |
69 | - foreach ($this->listeners[$name] as $i => $callable){ |
|
70 | - if ($listener === $callable){ |
|
69 | + foreach ($this->listeners[$name] as $i => $callable) { |
|
70 | + if ($listener === $callable) { |
|
71 | 71 | unset($this->listeners[$name][$i]); |
72 | 72 | $res = true; |
73 | 73 | } |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | * @param Callable|PEIP\INF\Handler\Handler $listener listener to connect |
84 | 84 | * @return |
85 | 85 | */ |
86 | - public function disconnectAll($name){ |
|
87 | - if (!isset($this->listeners[$name])){ |
|
86 | + public function disconnectAll($name) { |
|
87 | + if (!isset($this->listeners[$name])) { |
|
88 | 88 | return false; |
89 | 89 | } |
90 | 90 | $this->listeners[$name] = array(); |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | * @param string $name name of the event |
99 | 99 | * @return boolean wether any listener is registered for event-name |
100 | 100 | */ |
101 | - public function hasListeners($name){ |
|
102 | - if (!isset($this->listeners[$name])){ |
|
101 | + public function hasListeners($name) { |
|
102 | + if (!isset($this->listeners[$name])) { |
|
103 | 103 | return false; |
104 | 104 | } |
105 | - return (boolean) count($this->listeners[$name]); |
|
105 | + return (boolean)count($this->listeners[$name]); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -113,8 +113,8 @@ discard block |
||
113 | 113 | * @param mixed $subject the subject |
114 | 114 | * @return boolean success |
115 | 115 | */ |
116 | - public function notify($name, $subject){ |
|
117 | - if($this->hasListeners($name)){ |
|
116 | + public function notify($name, $subject) { |
|
117 | + if ($this->hasListeners($name)) { |
|
118 | 118 | self::doNotify($this->getListeners($name), $subject); |
119 | 119 | return true; |
120 | 120 | } |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | * @param mixed $subject the subject |
130 | 130 | * @return \PEIP\INF\Handler\Handler listener which returned a boolean true value |
131 | 131 | */ |
132 | - public function notifyUntil($name, $subject){ |
|
133 | - if($this->hasListeners($name)){ |
|
132 | + public function notifyUntil($name, $subject) { |
|
133 | + if ($this->hasListeners($name)) { |
|
134 | 134 | return self::doNotifyUntil($this->getListeners($name), $subject); |
135 | 135 | } |
136 | 136 | return NULL; |
@@ -143,8 +143,8 @@ discard block |
||
143 | 143 | * @param $name |
144 | 144 | * @return array array of \PEIP\INF\Handler\Handler instances |
145 | 145 | */ |
146 | - public function getListeners($name){ |
|
147 | - if (!isset($this->listeners[$name])){ |
|
146 | + public function getListeners($name) { |
|
147 | + if (!isset($this->listeners[$name])) { |
|
148 | 148 | return array(); |
149 | 149 | } |
150 | 150 | return $this->listeners[$name]; |
@@ -33,16 +33,16 @@ discard block |
||
33 | 33 | * @param mixed $subject subject to notify the listeners of |
34 | 34 | * @return void |
35 | 35 | */ |
36 | - protected static function doNotify(array $listeners, $subject){ |
|
37 | - foreach($listeners as $listener){ |
|
36 | + protected static function doNotify(array $listeners, $subject) { |
|
37 | + foreach ($listeners as $listener) { |
|
38 | 38 | self::doNotifyOne($listener, $subject); |
39 | 39 | } |
40 | 40 | } |
41 | 41 | |
42 | - protected static function doNotifyOne($listener, $subject){ |
|
43 | - if(is_callable($listener)){ |
|
42 | + protected static function doNotifyOne($listener, $subject) { |
|
43 | + if (is_callable($listener)) { |
|
44 | 44 | $res = call_user_func($listener, $subject); |
45 | - }else{ |
|
45 | + }else { |
|
46 | 46 | $res = $listener->handle($subject); |
47 | 47 | } |
48 | 48 | return $res; |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | * @param mixed $subject subject to notify the listeners of |
59 | 59 | * @return \PEIP\INF\Handler\Handler listener that returned a boolean true value |
60 | 60 | */ |
61 | - protected static function doNotifyUntil(array $listeners, $subject){ |
|
62 | - foreach ($listeners as $listener){ |
|
63 | - if (self::doNotifyOne($listener, $subject)){ |
|
61 | + protected static function doNotifyUntil(array $listeners, $subject) { |
|
62 | + foreach ($listeners as $listener) { |
|
63 | + if (self::doNotifyOne($listener, $subject)) { |
|
64 | 64 | return $listener; |
65 | 65 | } |
66 | 66 | } |
@@ -9,22 +9,22 @@ |
||
9 | 9 | protected $channel; |
10 | 10 | protected $handler; |
11 | 11 | |
12 | - public function __construct(\PEIP\ABS\Handler\MessageHandler $handler, $channel){ |
|
12 | + public function __construct(\PEIP\ABS\Handler\MessageHandler $handler, $channel) { |
|
13 | 13 | $this->channel = $channel; |
14 | 14 | $this->handler = $handler; |
15 | 15 | } |
16 | 16 | |
17 | - protected function getMessage($object){ |
|
18 | - if($this->channel instanceof \PEIP\INF\Channel\SubscribableChannel){ |
|
17 | + protected function getMessage($object) { |
|
18 | + if ($this->channel instanceof \PEIP\INF\Channel\SubscribableChannel) { |
|
19 | 19 | return $object; |
20 | - }else{ |
|
20 | + }else { |
|
21 | 21 | return $object->getContent()->receive(); |
22 | 22 | } |
23 | 23 | } |
24 | 24 | |
25 | - public function handle($object){ |
|
25 | + public function handle($object) { |
|
26 | 26 | $message = $this->getMessage($object); |
27 | - if(!is_object($message)){ |
|
27 | + if (!is_object($message)) { |
|
28 | 28 | throw new \Exception('Could not get Message from Channel'); |
29 | 29 | } |
30 | 30 | $this->handler->handle($message); |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @param $name |
34 | 34 | * @return |
35 | 35 | */ |
36 | - public static function getInstance(){ |
|
36 | + public static function getInstance() { |
|
37 | 37 | return self::$instance ? self::$instance : self::$instance = new ChannelRegistry; |
38 | 38 | } |
39 | 39 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @param $channel |
44 | 44 | * @return |
45 | 45 | */ |
46 | - public function register($channel){ |
|
46 | + public function register($channel) { |
|
47 | 47 | $this->channels[$channel->getName()] = $channel; |
48 | 48 | } |
49 | 49 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * @param $name |
56 | 56 | * @return |
57 | 57 | */ |
58 | - public function get($name){ |
|
58 | + public function get($name) { |
|
59 | 59 | return $this->channels[$name]; |
60 | 60 | } |
61 | 61 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @param $channelName |
66 | 66 | * @return |
67 | 67 | */ |
68 | - public function resolveChannelName($channelName){ |
|
68 | + public function resolveChannelName($channelName) { |
|
69 | 69 | return $this->get($channelName); |
70 | 70 | } |
71 | 71 |
@@ -35,7 +35,7 @@ |
||
35 | 35 | * @param $message |
36 | 36 | * @return |
37 | 37 | */ |
38 | - protected function doSend(\PEIP\INF\Message\Message $message){ |
|
38 | + protected function doSend(\PEIP\INF\Message\Message $message) { |
|
39 | 39 | $this->doFireEvent('prePublish', array('MESSAGE'=>$message)); |
40 | 40 | $this->getMessageDispatcher()->notify($message); |
41 | 41 | $this->doFireEvent('postPublish', array('MESSAGE'=>$message)); |