@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | abstract class SubscribableChannel |
31 | 31 | extends \PEIP\ABS\Channel\Channel |
32 | - implements \PEIP\INF\Channel\SubscribableChannel{ |
|
32 | + implements \PEIP\INF\Channel\SubscribableChannel { |
|
33 | 33 | |
34 | 34 | protected $messageDispatcher; |
35 | 35 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @param Callable|PEIP\INF\Handler\Handler $handler the listener to subscribe |
42 | 42 | * @return |
43 | 43 | */ |
44 | - public function subscribe($handler){ |
|
44 | + public function subscribe($handler) { |
|
45 | 45 | Test::ensureHandler($handler); |
46 | 46 | $this->getMessageDispatcher()->connect($handler); |
47 | 47 | $this->doFireEvent('subscribe', array('SUBSCRIBER'=>$handler)); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * @param Callable|PEIP\INF\Handler\Handler $handler the listener to unsubscribe |
56 | 56 | * @return |
57 | 57 | */ |
58 | - public function unsubscribe($handler){ |
|
58 | + public function unsubscribe($handler) { |
|
59 | 59 | Test::ensureHandler($handler); |
60 | 60 | $this->getMessageDispatcher()->disconnect($handler); |
61 | 61 | $this->doFireEvent('unsubscribe', array('SUBSCRIBER'=>$handler)); |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | * @param boolean $transferListeners wether to transfer listeners of old dispatcher (if set) to new one. default: true |
70 | 70 | * @return |
71 | 71 | */ |
72 | - public function setMessageDispatcher(\PEIP\INF\Dispatcher\Dispatcher $dispatcher, $transferListeners = true){ |
|
73 | - if(isset($this->dispatcher) && $transferListeners){ |
|
74 | - foreach($this->dispatcher->getListeners() as $listener){ |
|
72 | + public function setMessageDispatcher(\PEIP\INF\Dispatcher\Dispatcher $dispatcher, $transferListeners = true) { |
|
73 | + if (isset($this->dispatcher) && $transferListeners) { |
|
74 | + foreach ($this->dispatcher->getListeners() as $listener) { |
|
75 | 75 | $dispatcher->connect($listener); |
76 | 76 | $this->dispatcher->disconnect($listener); |
77 | 77 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * @access public |
86 | 86 | * @return |
87 | 87 | */ |
88 | - public function getMessageDispatcher(){ |
|
88 | + public function getMessageDispatcher() { |
|
89 | 89 | return isset($this->dispatcher) ? $this->dispatcher : $this->dispatcher = new Dispatcher; |
90 | 90 | } |
91 | 91 |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @param $name |
35 | 35 | * @return |
36 | 36 | */ |
37 | - public function __construct($name){ |
|
37 | + public function __construct($name) { |
|
38 | 38 | $this->name = $name; |
39 | 39 | } |
40 | 40 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @access public |
43 | 43 | * @return string the channel�s name |
44 | 44 | */ |
45 | - public function getName(){ |
|
45 | + public function getName() { |
|
46 | 46 | return $this->name; |
47 | 47 | } |
48 | 48 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @param integer $timeout |
53 | 53 | * @return |
54 | 54 | */ |
55 | - public function send(\PEIP\INF\Message\Message $message, $timeout = -1){ |
|
55 | + public function send(\PEIP\INF\Message\Message $message, $timeout = -1) { |
|
56 | 56 | $this->doFireEvent('preSend', array('MESSAGE'=>$message)); |
57 | 57 | $sent = $this->doSend($message); |
58 | 58 | $this->doFireEvent('postSend', array( |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @access public |
41 | 41 | * @return |
42 | 42 | */ |
43 | - public function __invoke(){ |
|
43 | + public function __invoke() { |
|
44 | 44 | return $this->execute(); |
45 | 45 | } |
46 | 46 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * @access public |
52 | 52 | * @return |
53 | 53 | */ |
54 | - public function execute(){ |
|
54 | + public function execute() { |
|
55 | 55 | return call_user_func_array($this->callable, $this->getParameters()); |
56 | 56 | } |
57 | 57 |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | * @param \PEIP\INF\Context\Context $context context instance to register the plugin with |
41 | 41 | * @return |
42 | 42 | */ |
43 | - public function init(\PEIP\INF\Context\Context $context){ |
|
43 | + public function init(\PEIP\INF\Context\Context $context) { |
|
44 | 44 | $this->context = $context; |
45 | - foreach($this->builders as $node=>$method){ |
|
45 | + foreach ($this->builders as $node=>$method) { |
|
46 | 46 | $context->registerNodeBuilder($node, array($this, $method)); |
47 | 47 | } |
48 | 48 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @param string $defaultClass class to create instance for if none is set in config |
60 | 60 | * @return object build and modified srvice instance |
61 | 61 | */ |
62 | - public function buildAndModify($config, $arguments, $defaultClass = false){ |
|
62 | + public function buildAndModify($config, $arguments, $defaultClass = false) { |
|
63 | 63 | return ServiceFactory::buildAndModify($config, $arguments, $defaultClass); |
64 | 64 | } |
65 | 65 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * @param $connection |
38 | 38 | * @return |
39 | 39 | */ |
40 | - public function setConnection($connection){ |
|
40 | + public function setConnection($connection) { |
|
41 | 41 | $this->connection = $connection; |
42 | 42 | } |
43 | 43 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @access public |
48 | 48 | * @return |
49 | 49 | */ |
50 | - public function execute(){ |
|
50 | + public function execute() { |
|
51 | 51 | return $this->send(); |
52 | 52 | } |
53 | 53 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @access public |
57 | 57 | * @return |
58 | 58 | */ |
59 | - public function send(){ |
|
59 | + public function send() { |
|
60 | 60 | return $this->connection->sendRequest($this); |
61 | 61 | } |
62 | 62 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @access public |
66 | 66 | * @return |
67 | 67 | */ |
68 | - public function getRequestData(){ |
|
68 | + public function getRequestData() { |
|
69 | 69 | return $this->doGetRequestData(); |
70 | 70 | } |
71 | 71 |
@@ -34,7 +34,7 @@ |
||
34 | 34 | * @param $request |
35 | 35 | * @return |
36 | 36 | */ |
37 | - public function sendRequest(\PEIP\ABS\Request\Request $request){ |
|
37 | + public function sendRequest(\PEIP\ABS\Request\Request $request) { |
|
38 | 38 | return $this->doSendRequest($request); |
39 | 39 | } |
40 | 40 |
@@ -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 |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @param \PEIP\INF\Channel\Channel $outputChannel the output-channel |
45 | 45 | * @return \PEIP\ABS\Handler\MessageHandler $this; |
46 | 46 | */ |
47 | - public function setOutputChannel(\PEIP\INF\Channel\Channel $outputChannel){ |
|
47 | + public function setOutputChannel(\PEIP\INF\Channel\Channel $outputChannel) { |
|
48 | 48 | $this->doSetOutputChannel($outputChannel); |
49 | 49 | return $this; |
50 | 50 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @param \PEIP\INF\Channel\Channel $inputChannel the output-channel to connect the handler to |
57 | 57 | * @return |
58 | 58 | */ |
59 | - protected function doSetOutputChannel(\PEIP\INF\Channel\Channel $outputChannel){ |
|
59 | + protected function doSetOutputChannel(\PEIP\INF\Channel\Channel $outputChannel) { |
|
60 | 60 | $this->outputChannel = $outputChannel; |
61 | 61 | } |
62 | 62 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @access public |
67 | 67 | * @return \PEIP\INF\Channel\Channel output-channel for this handler |
68 | 68 | */ |
69 | - public function getOutputChannel(){ |
|
69 | + public function getOutputChannel() { |
|
70 | 70 | return $this->outputChannel; |
71 | 71 | } |
72 | 72 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * @param \PEIP\INF\Message\Message $message the message to resolve output-channel for |
81 | 81 | * @return \PEIP\INF\Channel\Channel the output-channel for the message |
82 | 82 | */ |
83 | - protected function doGetOutputChannel(\PEIP\INF\Message\Message $message){ |
|
83 | + protected function doGetOutputChannel(\PEIP\INF\Message\Message $message) { |
|
84 | 84 | $replyChannel = $this->resolveReplyChannel($message); |
85 | 85 | return $replyChannel ? $replyChannel : $this->getOutputChannel(); |
86 | 86 | } |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | * @param \PEIP\INF\Message\Message $message |
95 | 95 | * @return \PEIP\INF\Channel\Channel the reply-channel if found |
96 | 96 | */ |
97 | - protected function resolveReplyChannel(\PEIP\INF\Message\Message $message){ |
|
98 | - foreach($this->replyChannelHeaders as $header){ |
|
99 | - if($message->hasHeader($header)){ |
|
97 | + protected function resolveReplyChannel(\PEIP\INF\Message\Message $message) { |
|
98 | + foreach ($this->replyChannelHeaders as $header) { |
|
99 | + if ($message->hasHeader($header)) { |
|
100 | 100 | return $message->getHeader($header); |
101 | 101 | } |
102 | 102 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * @access protected |
114 | 114 | * @param mixed $content \PEIP\INF\Message\Message or content/payload for new message |
115 | 115 | */ |
116 | - protected function replyMessage($content){ |
|
116 | + protected function replyMessage($content) { |
|
117 | 117 | $message = $this->ensureMessage($content); |
118 | 118 | $this->doGetOutputChannel($message)->send($message); |
119 | 119 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * @param mixed $message \PEIP\INF\Message\Message or content/payload for new message |
128 | 128 | * @return \PEIP\INF\Message\Message |
129 | 129 | */ |
130 | - protected function ensureMessage($message){ |
|
130 | + protected function ensureMessage($message) { |
|
131 | 131 | return ($message instanceof \PEIP\INF\Message\Message) ? $message : $this->buildMessage($message); |
132 | 132 | } |
133 | 133 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @return \PEIP\INF\Message\Message |
141 | 141 | * @see MessageBuilder |
142 | 142 | */ |
143 | - protected function buildMessage($content){ |
|
143 | + protected function buildMessage($content) { |
|
144 | 144 | return $this->getMessageBuilder()->setContent($content)->build(); |
145 | 145 | } |
146 | 146 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * @access protected |
152 | 152 | * @return MessageBuilder builder for the registered message class |
153 | 153 | */ |
154 | - protected function getMessageBuilder(){ |
|
154 | + protected function getMessageBuilder() { |
|
155 | 155 | return isset($this->messageBuilder) && ($this->messageBuilder->getMessageClass() == $this->getMessageClass()) |
156 | 156 | ? $this->messageBuilder |
157 | 157 | : $this->messageBuilder = MessageBuilder::getInstance($this->messageClass); |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | * @param string $messageClass name of the message-class to create reply-messages from. |
165 | 165 | * @return PEIP\ABS\Handler\ReplyProducingMessageHandler $this |
166 | 166 | */ |
167 | - public function setMessageClass($messageClass){ |
|
167 | + public function setMessageClass($messageClass) { |
|
168 | 168 | $this->messageClass = $messageClass; |
169 | 169 | return $this; |
170 | 170 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | * @access public |
176 | 176 | * @return string name of the message-class to create reply-messages from. |
177 | 177 | */ |
178 | - public function getMessageClass(){ |
|
178 | + public function getMessageClass() { |
|
179 | 179 | return $this->messageClass; |
180 | 180 | } |
181 | 181 | |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | * @param string $headerName name of a message-header to look for a reply-channel |
187 | 187 | * @return void |
188 | 188 | */ |
189 | - public function addReplyChannelHeader($headerName){ |
|
189 | + public function addReplyChannelHeader($headerName) { |
|
190 | 190 | $this->replyChannelHeaders[] = $headerName; |
191 | 191 | } |
192 | 192 | |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * @param array $headerNames array of message-header names to look for a reply-channel |
198 | 198 | * @return PEIP\ABS\Handler\ReplyProducingMessageHandler $this |
199 | 199 | */ |
200 | - public function setReplyChannelHeaders(array $headerNames){ |
|
200 | + public function setReplyChannelHeaders(array $headerNames) { |
|
201 | 201 | $this->replyChannelHeaders = $headerNames; |
202 | 202 | return $this; |
203 | 203 | } |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | * @access public |
209 | 209 | * @return array array of message-header names to look for a reply-channel |
210 | 210 | */ |
211 | - public function getReplyChannelHeaders(){ |
|
211 | + public function getReplyChannelHeaders() { |
|
212 | 212 | return $this->replyChannelHeaders; |
213 | 213 | } |
214 | 214 | |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | * @param \PEIP\INF\Message\Message $message |
223 | 223 | * @return |
224 | 224 | */ |
225 | - protected function doHandle(\PEIP\INF\Message\Message $message){ |
|
225 | + protected function doHandle(\PEIP\INF\Message\Message $message) { |
|
226 | 226 | return $this->doReply($message); |
227 | 227 | } |
228 | 228 |
@@ -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 | } |