@@ -5,20 +5,20 @@ |
||
5 | 5 | |
6 | 6 | class OrderSplitter extends MessageSplitter { |
7 | 7 | |
8 | - public function split(Message $message){ |
|
9 | - $order = $message->getContent(); |
|
10 | - $orderItems = $order->getItems(); |
|
11 | - $items = array(); |
|
12 | - foreach($orderItems as $item){ |
|
13 | - $nr = $item['number']; |
|
14 | - unset($item['number']); |
|
15 | - $item['order'] = $order->getOrderNumber(); |
|
16 | - for($x = 0; $x < $nr; $x++){ |
|
17 | - $items[] = $item; |
|
18 | - } |
|
19 | - } |
|
20 | - echo PEIP_LINE_SEPARATOR."OrderSplitter: split order #: ".$order->getOrderNumber(); |
|
21 | - return $items; |
|
22 | - } |
|
8 | + public function split(Message $message){ |
|
9 | + $order = $message->getContent(); |
|
10 | + $orderItems = $order->getItems(); |
|
11 | + $items = array(); |
|
12 | + foreach($orderItems as $item){ |
|
13 | + $nr = $item['number']; |
|
14 | + unset($item['number']); |
|
15 | + $item['order'] = $order->getOrderNumber(); |
|
16 | + for($x = 0; $x < $nr; $x++){ |
|
17 | + $items[] = $item; |
|
18 | + } |
|
19 | + } |
|
20 | + echo PEIP_LINE_SEPARATOR."OrderSplitter: split order #: ".$order->getOrderNumber(); |
|
21 | + return $items; |
|
22 | + } |
|
23 | 23 | |
24 | 24 | } |
@@ -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 | } |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | class Cafe |
4 | - extends \PEIP\Gateway\SimpleMessagingGateway { |
|
4 | + extends \PEIP\Gateway\SimpleMessagingGateway { |
|
5 | 5 | |
6 | - public function placeOrder(Order $order){ |
|
7 | - return $this->sendAndReceive($order); |
|
8 | - } |
|
6 | + public function placeOrder(Order $order){ |
|
7 | + return $this->sendAndReceive($order); |
|
8 | + } |
|
9 | 9 | |
10 | 10 | } |
11 | 11 |
@@ -3,7 +3,7 @@ |
||
3 | 3 | class Cafe |
4 | 4 | extends \PEIP\Gateway\SimpleMessagingGateway { |
5 | 5 | |
6 | - public function placeOrder(Order $order){ |
|
6 | + public function placeOrder(Order $order) { |
|
7 | 7 | return $this->sendAndReceive($order); |
8 | 8 | } |
9 | 9 |
@@ -9,9 +9,9 @@ |
||
9 | 9 | // simple service class |
10 | 10 | class HelloService { |
11 | 11 | |
12 | - public function greet($name){ |
|
13 | - return 'Hello '.$name; |
|
14 | - } |
|
12 | + public function greet($name){ |
|
13 | + return 'Hello '.$name; |
|
14 | + } |
|
15 | 15 | |
16 | 16 | } |
17 | 17 |
@@ -9,7 +9,7 @@ |
||
9 | 9 | // simple service class |
10 | 10 | class HelloService { |
11 | 11 | |
12 | - public function greet($name){ |
|
12 | + public function greet($name) { |
|
13 | 13 | return 'Hello '.$name; |
14 | 14 | } |
15 | 15 |
@@ -38,7 +38,7 @@ |
||
38 | 38 | |
39 | 39 | /** |
40 | 40 | * @access public |
41 | - * @param $name |
|
41 | + * @param string $name |
|
42 | 42 | * @param Callable|PEIP\INF\Handler\Handler $listener |
43 | 43 | * @return |
44 | 44 | */ |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | * @subpackage base |
18 | 18 | */ |
19 | 19 | |
20 | -abstract class Connectable implements \PEIP\INF\Event\Connectable{ |
|
20 | +abstract class Connectable implements \PEIP\INF\Event\Connectable { |
|
21 | 21 | |
22 | 22 | const |
23 | 23 | DEFAULT_CLASS_MESSAGE_DISPATCHER = '\PEIP\Dispatcher\Dispatcher', |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @param Callable|PEIP\INF\Handler\Handler $listener |
43 | 43 | * @return |
44 | 44 | */ |
45 | - public function connect($name, $listener){ |
|
45 | + public function connect($name, $listener) { |
|
46 | 46 | \PEIP\Util\Test::ensureHandler($listener); |
47 | 47 | $this->getEventDispatcher()->connect($name, $this, $listener); |
48 | 48 | $this->doFireEvent( |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * @param Callable|PEIP\INF\Handler\Handler $listener |
62 | 62 | * @return |
63 | 63 | */ |
64 | - public function disconnect($name, $listener){ |
|
64 | + public function disconnect($name, $listener) { |
|
65 | 65 | \PEIP\Util\Test::ensureHandler($listener); |
66 | 66 | $this->getEventDispatcher()->disconnect($name, $this, $listener); |
67 | 67 | $this->doFireEvent( |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @param $name |
83 | 83 | * @return |
84 | 84 | */ |
85 | - public function hasListeners($name){ |
|
85 | + public function hasListeners($name) { |
|
86 | 86 | return $this->getEventDispatcher()->hasListeners($name, $this); |
87 | 87 | } |
88 | 88 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * @param $name |
93 | 93 | * @return |
94 | 94 | */ |
95 | - public function getListeners($name){ |
|
95 | + public function getListeners($name) { |
|
96 | 96 | return $this->getEventDispatcher()->getListeners($name, $this); |
97 | 97 | } |
98 | 98 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @param $callable |
103 | 103 | * @return |
104 | 104 | */ |
105 | - public function disconnectAll($name){ |
|
105 | + public function disconnectAll($name) { |
|
106 | 106 | $this->getEventDispatcher()->disconnectAll($name, $this); |
107 | 107 | } |
108 | 108 | |
@@ -112,11 +112,11 @@ discard block |
||
112 | 112 | * @param $transferListners |
113 | 113 | * @return |
114 | 114 | */ |
115 | - public function setEventDispatcher(\PEIP\Dispatcher\ObjectEventDispatcher $dispatcher, $transferListners = true){ |
|
116 | - if($transferListners){ |
|
117 | - foreach($this->getEventDispatcher()->getEventNames($this) as $name){ |
|
118 | - if($this->getEventDispatcher()->hasListeners($name, $this)){ |
|
119 | - foreach($this->getEventDispatcher()->getListeners($name, $this) as $listener){ |
|
115 | + public function setEventDispatcher(\PEIP\Dispatcher\ObjectEventDispatcher $dispatcher, $transferListners = true) { |
|
116 | + if ($transferListners) { |
|
117 | + foreach ($this->getEventDispatcher()->getEventNames($this) as $name) { |
|
118 | + if ($this->getEventDispatcher()->hasListeners($name, $this)) { |
|
119 | + foreach ($this->getEventDispatcher()->getListeners($name, $this) as $listener) { |
|
120 | 120 | $dispatcher->connect($name, $this, $listener); |
121 | 121 | } |
122 | 122 | } |
@@ -131,11 +131,11 @@ discard block |
||
131 | 131 | * @access public |
132 | 132 | * @return |
133 | 133 | */ |
134 | - public function getEventDispatcher(){ |
|
134 | + public function getEventDispatcher() { |
|
135 | 135 | return $this->eventDispatcher ? $this->eventDispatcher : $this->eventDispatcher = self::getSharedEventDispatcher(); |
136 | 136 | } |
137 | 137 | |
138 | - protected static function getSharedEventDispatcher(){ |
|
138 | + protected static function getSharedEventDispatcher() { |
|
139 | 139 | $defaultDispatcher = self::DEFAULT_CLASS_EVENT_DISPATCHER; |
140 | 140 | return self::$sharedEventDispatcher ? self::$sharedEventDispatcher : self::$sharedEventDispatcher = new $defaultDispatcher; |
141 | 141 | } |
@@ -148,12 +148,12 @@ discard block |
||
148 | 148 | * @param $eventClass |
149 | 149 | * @return |
150 | 150 | */ |
151 | - protected function doFireEvent($name, array $headers = array(), $eventClass = '', $type = false){ |
|
151 | + protected function doFireEvent($name, array $headers = array(), $eventClass = '', $type = false) { |
|
152 | 152 | $eventClass = trim($eventClass) == '' ? static::DEFAULT_EVENT_CLASS : $eventClass; |
153 | 153 | return $this->getEventDispatcher()->buildAndNotify($name, $this, $headers, $eventClass, $type); |
154 | 154 | } |
155 | 155 | |
156 | - protected static function getDefaultEventClass(){ |
|
156 | + protected static function getDefaultEventClass() { |
|
157 | 157 | return self::DEFAULT_EVENT_CLASS; |
158 | 158 | } |
159 | 159 | } |
@@ -80,7 +80,6 @@ |
||
80 | 80 | * |
81 | 81 | * @access public |
82 | 82 | * @param string $name name of the event |
83 | - * @param Callable|PEIP\INF\Handler\Handler $listener listener to connect |
|
84 | 83 | * @return |
85 | 84 | */ |
86 | 85 | public function disconnectAll($name){ |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | public function connect($name, $listener){ |
48 | 48 | Test::ensureHandler($listener); |
49 | 49 | if (!$this->hasListeners($name)){ |
50 | - $this->listeners[$name] = array(); |
|
50 | + $this->listeners[$name] = array(); |
|
51 | 51 | } |
52 | 52 | $this->listeners[$name][] = $listener; |
53 | 53 | return true; |
@@ -67,10 +67,10 @@ discard block |
||
67 | 67 | } |
68 | 68 | $res = false; |
69 | 69 | foreach ($this->listeners[$name] as $i => $callable){ |
70 | - if ($listener === $callable){ |
|
70 | + if ($listener === $callable){ |
|
71 | 71 | unset($this->listeners[$name][$i]); |
72 | 72 | $res = true; |
73 | - } |
|
73 | + } |
|
74 | 74 | } |
75 | 75 | return $res; |
76 | 76 | } |
@@ -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]; |
@@ -54,7 +54,7 @@ |
||
54 | 54 | * @see PEIP\ABS\Handler\MessageHandler::doSetInputChannel |
55 | 55 | * @access public |
56 | 56 | * @param \PEIP\INF\Channel\Channel $inputChannel the input-channel |
57 | - * @return PEIP\ABS\Handler\MessageHandler $this; |
|
57 | + * @return MessageHandler $this; |
|
58 | 58 | */ |
59 | 59 | public function setInputChannel(\PEIP\INF\Channel\Channel $inputChannel){ |
60 | 60 | $this->doSetInputChannel($inputChannel); |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @return |
44 | 44 | */ |
45 | 45 | public function handle($message){ |
46 | - $this->doHandle($this->getMessageFromObject($message)); |
|
46 | + $this->doHandle($this->getMessageFromObject($message)); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -90,7 +90,7 @@ discard block |
||
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)) { |
@@ -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 |
@@ -77,7 +77,7 @@ |
||
77 | 77 | $this->inputChannel = $inputChannel; |
78 | 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 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * Connects the handler to the output-channel. |
52 | 52 | * |
53 | 53 | * @access protected |
54 | - * @param \PEIP\INF\Channel\Channel $inputChannel the output-channel to connect the handler to |
|
54 | + * @param \PEIP\INF\Channel\Channel $outputChannel the output-channel to connect the handler to |
|
55 | 55 | * @return |
56 | 56 | */ |
57 | 57 | protected function doSetOutputChannel(\PEIP\INF\Channel\Channel $outputChannel){ |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * |
161 | 161 | * @access public |
162 | 162 | * @param string $messageClass name of the message-class to create reply-messages from. |
163 | - * @return PEIP\ABS\Handler\ReplyProducingMessageHandler $this |
|
163 | + * @return ReplyProducingMessageHandler $this |
|
164 | 164 | */ |
165 | 165 | public function setMessageClass($messageClass){ |
166 | 166 | $this->messageClass = $messageClass; |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | * |
194 | 194 | * @access public |
195 | 195 | * @param array $headerNames array of message-header names to look for a reply-channel |
196 | - * @return PEIP\ABS\Handler\ReplyProducingMessageHandler $this |
|
196 | + * @return ReplyProducingMessageHandler $this |
|
197 | 197 | */ |
198 | 198 | public function setReplyChannelHeaders(array $headerNames){ |
199 | 199 | $this->replyChannelHeaders = $headerNames; |
@@ -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 |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @implements \PEIP\INF\Context\Context |
137 | 137 | * @access public |
138 | - * @param \PEIP\INF\Context\Context_Plugin $plugin a plugin instance |
|
138 | + * @param \PEIP\INF\Context\ContextPlugin $plugin a plugin instance |
|
139 | 139 | */ |
140 | 140 | public function addPlugin(\PEIP\INF\Context\ContextPlugin $plugin){ |
141 | 141 | $plugin->init($this); |
@@ -167,7 +167,6 @@ discard block |
||
167 | 167 | * </config> |
168 | 168 | * |
169 | 169 | * @access public |
170 | - * @param XMLContext $config the config to include |
|
171 | 170 | */ |
172 | 171 | public function includeContext(XMLContext $context){ |
173 | 172 | $this->services = array_merge($this->services, $context->getServices()); |
@@ -178,7 +177,7 @@ discard block |
||
178 | 177 | * |
179 | 178 | * @see XMLContext::includeContext |
180 | 179 | * @access public |
181 | - * @param XMLContext $context the config to include |
|
180 | + * @param string $filePath |
|
182 | 181 | */ |
183 | 182 | public function includeContextFromFile($filePath){ |
184 | 183 | if(file_exists($filePath)){ |
@@ -357,7 +356,7 @@ discard block |
||
357 | 356 | * |
358 | 357 | * @access public |
359 | 358 | * @param $config |
360 | - * @return object the initialized service instance |
|
359 | + * @return \PEIP\INF\Context\ContextPlugin the initialized service instance |
|
361 | 360 | */ |
362 | 361 | public function createService($config){ |
363 | 362 | return ServiceFactory::createService($config); |
@@ -685,7 +684,7 @@ discard block |
||
685 | 684 | * |
686 | 685 | * @access protected |
687 | 686 | * @param object $config configuration object to create arguments from. |
688 | - * @return mixed build arguments |
|
687 | + * @return \PEIP\INF\Channel\Channel[] build arguments |
|
689 | 688 | */ |
690 | 689 | protected function getReplyHandlerArguments($config){ |
691 | 690 | $args = array( |
@@ -730,7 +729,8 @@ discard block |
||
730 | 729 | * |
731 | 730 | * @access protected |
732 | 731 | * @param string the configuration type ofthe channel (e.g.: 'reply', 'request') |
733 | - * @param object $config configuration object to return channel from. |
|
732 | + * @param object $config configuration object to return channel from. |
|
733 | + * @param string $type |
|
734 | 734 | * @return \PEIP\INF\Channel\Channel reply-channel |
735 | 735 | */ |
736 | 736 | public function doGetChannel($type, $config){ |
@@ -793,7 +793,7 @@ discard block |
||
793 | 793 | * @see GenericBuilder |
794 | 794 | * @static |
795 | 795 | * @access protected |
796 | - * @param object $className name of class to build instance for. |
|
796 | + * @param string $className name of class to build instance for. |
|
797 | 797 | * @param array $arguments arguments for the constructor |
798 | 798 | * @return object build and modified srvice instance |
799 | 799 | */ |
@@ -801,6 +801,10 @@ discard block |
||
801 | 801 | return GenericBuilder::getInstance($className)->build($arguments); |
802 | 802 | } |
803 | 803 | |
804 | + /** |
|
805 | + * @param string $type |
|
806 | + * @param string $name |
|
807 | + */ |
|
804 | 808 | protected static function hasPublicProperty($service, $type, $name){ |
805 | 809 | $reflection = GenericBuilder::getInstance(get_class($service))->getReflectionClass(); |
806 | 810 | if($reflection->{'has'.$type}($name) && $reflection->{'get'.$type}($name)->isPublic()){ |
@@ -127,7 +127,7 @@ |
||
127 | 127 | * @param callable $callable a callable which creates instances for node-name |
128 | 128 | */ |
129 | 129 | public function registerNodeBuilder($nodeName, $callable){ |
130 | - return $this->getServiceProvider()->registerNodeBuilder($nodeName, $callable); |
|
130 | + return $this->getServiceProvider()->registerNodeBuilder($nodeName, $callable); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -50,24 +50,24 @@ discard block |
||
50 | 50 | * @param string $string the configuration string |
51 | 51 | * @return |
52 | 52 | */ |
53 | - public function __construct($string){ |
|
53 | + public function __construct($string) { |
|
54 | 54 | $this->initNodeBuilders(); |
55 | 55 | $reader = new XMLContextReader($string); |
56 | 56 | |
57 | 57 | |
58 | 58 | $serviceActivator = new HeaderServiceActivator(array($this, 'addConfig'), 'NODE'); |
59 | 59 | |
60 | - $reader->connect('read_node', $serviceActivator); |
|
60 | + $reader->connect('read_node', $serviceActivator); |
|
61 | 61 | $reader->read(); |
62 | 62 | |
63 | 63 | |
64 | 64 | } |
65 | 65 | |
66 | - public function addConfig($config){ |
|
66 | + public function addConfig($config) { |
|
67 | 67 | return $this->getServiceProvider()->addConfig($config); |
68 | 68 | } |
69 | 69 | |
70 | - public function handleReadConfig(\PEIP\INF\Event\Event $event){ |
|
70 | + public function handleReadConfig(\PEIP\INF\Event\Event $event) { |
|
71 | 71 | $this->addConfig($event->getHeader('NODE')); |
72 | 72 | } |
73 | 73 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * @return XMLContext the context instance |
80 | 80 | * @throws RuntimeException |
81 | 81 | */ |
82 | - public static function createFromString($string){ |
|
82 | + public static function createFromString($string) { |
|
83 | 83 | return new XMLContext($string); |
84 | 84 | } |
85 | 85 | |
@@ -91,10 +91,10 @@ discard block |
||
91 | 91 | * @return XMLContext the context instance |
92 | 92 | * @throws RuntimeException |
93 | 93 | */ |
94 | - public static function createFromFile($file){ |
|
95 | - if(file_exists($file)){ |
|
94 | + public static function createFromFile($file) { |
|
95 | + if (file_exists($file)) { |
|
96 | 96 | return self::createFromString(file_get_contents($file)); |
97 | - }else{ |
|
97 | + }else { |
|
98 | 98 | throw new \RuntimeException('Cannot open file "'.$file.'".'); |
99 | 99 | } |
100 | 100 | } |
@@ -105,15 +105,15 @@ discard block |
||
105 | 105 | * @access protected |
106 | 106 | * @return void |
107 | 107 | */ |
108 | - protected function init(){ |
|
108 | + protected function init() { |
|
109 | 109 | $xml = $this->simpleXML; |
110 | 110 | $this->channelRegistry = ChannelRegistry::getInstance(); |
111 | 111 | // register this context as a service if id is set. |
112 | - if($xml['id']){ |
|
112 | + if ($xml['id']) { |
|
113 | 113 | $this->services[(string)$xml['id']] = $this; |
114 | 114 | } |
115 | 115 | // build services |
116 | - foreach($xml->children() as $entry){ |
|
116 | + foreach ($xml->children() as $entry) { |
|
117 | 117 | $this->buildNode($entry); |
118 | 118 | } |
119 | 119 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @param string $nodeName the name of the node |
127 | 127 | * @param callable $callable a callable which creates instances for node-name |
128 | 128 | */ |
129 | - public function registerNodeBuilder($nodeName, $callable){ |
|
129 | + public function registerNodeBuilder($nodeName, $callable) { |
|
130 | 130 | return $this->getServiceProvider()->registerNodeBuilder($nodeName, $callable); |
131 | 131 | } |
132 | 132 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * @access public |
138 | 138 | * @param \PEIP\INF\Context\Context_Plugin $plugin a plugin instance |
139 | 139 | */ |
140 | - public function addPlugin(\PEIP\INF\Context\ContextPlugin $plugin){ |
|
140 | + public function addPlugin(\PEIP\INF\Context\ContextPlugin $plugin) { |
|
141 | 141 | $plugin->init($this); |
142 | 142 | } |
143 | 143 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * @param object $config configuration object for the plugin |
149 | 149 | * @return |
150 | 150 | */ |
151 | - public function createPlugin($config){ |
|
151 | + public function createPlugin($config) { |
|
152 | 152 | $plugin = $this->createService($config); |
153 | 153 | $this->addPlugin($plugin); |
154 | 154 | } |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * @access public |
170 | 170 | * @param XMLContext $config the config to include |
171 | 171 | */ |
172 | - public function includeContext(XMLContext $context){ |
|
172 | + public function includeContext(XMLContext $context) { |
|
173 | 173 | $this->services = array_merge($this->services, $context->getServices()); |
174 | 174 | } |
175 | 175 | |
@@ -180,8 +180,8 @@ discard block |
||
180 | 180 | * @access public |
181 | 181 | * @param XMLContext $context the config to include |
182 | 182 | */ |
183 | - public function includeContextFromFile($filePath){ |
|
184 | - if(file_exists($filePath)){ |
|
183 | + public function includeContextFromFile($filePath) { |
|
184 | + if (file_exists($filePath)) { |
|
185 | 185 | $this->includeContextFromString(file_get_contents($filePath)); |
186 | 186 | } |
187 | 187 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | * @access public |
194 | 194 | * @param string $configString the config to include |
195 | 195 | */ |
196 | - public function includeContextFromString($configString){ |
|
196 | + public function includeContextFromString($configString) { |
|
197 | 197 | $context = new XMLContext($configString); |
198 | 198 | $this->includeContext($context); |
199 | 199 | } |
@@ -205,14 +205,14 @@ discard block |
||
205 | 205 | * @access protected |
206 | 206 | * @param object $config the configuration for the context |
207 | 207 | */ |
208 | - protected function createContext($config){ |
|
209 | - if((string)$config['file'] != ''){ |
|
208 | + protected function createContext($config) { |
|
209 | + if ((string)$config['file'] != '') { |
|
210 | 210 | $this->includeContextFromFile((string)$config['file']); |
211 | 211 | } |
212 | 212 | } |
213 | 213 | |
214 | 214 | |
215 | - public function getServiceProvider(){ |
|
215 | + public function getServiceProvider() { |
|
216 | 216 | return isset($this->serviceProvider) |
217 | 217 | ? $this->serviceProvider |
218 | 218 | : $this->serviceProvider = new ServiceProvider(); |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | * @see XMLContext::includeContext |
229 | 229 | * @access protected |
230 | 230 | */ |
231 | - protected function initNodeBuilders(){ |
|
231 | + protected function initNodeBuilders() { |
|
232 | 232 | $builders = array( |
233 | 233 | 'include' => 'createContext', |
234 | 234 | 'plugin' => 'createPlugin', |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | ); |
247 | 247 | $plugin = new BasePlugin(); |
248 | 248 | $this->addPlugin($plugin); |
249 | - foreach($builders as $nodeName => $method){ |
|
249 | + foreach ($builders as $nodeName => $method) { |
|
250 | 250 | $this->registerNodeBuilder($nodeName, array($this, $method)); |
251 | 251 | } |
252 | 252 | } |
@@ -260,10 +260,10 @@ discard block |
||
260 | 260 | * @param object $node configuration-node |
261 | 261 | * @return void |
262 | 262 | */ |
263 | - protected function buildNode($node){ |
|
263 | + protected function buildNode($node) { |
|
264 | 264 | $nodeName = $node->getName(); |
265 | 265 | // call the builder method registered for the node. |
266 | - if(array_key_exists($nodeName, $this->nodeBuilders)){ |
|
266 | + if (array_key_exists($nodeName, $this->nodeBuilders)) { |
|
267 | 267 | call_user_func($this->nodeBuilders[$nodeName], $node); |
268 | 268 | } |
269 | 269 | } |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * @param string $channelName the name/id of the channel to return |
283 | 283 | * @return \PEIP\INF\Channel\Channel |
284 | 284 | */ |
285 | - public function resolveChannelName($channelName){ |
|
285 | + public function resolveChannelName($channelName) { |
|
286 | 286 | return $this->channelRegistry->get($channelName); |
287 | 287 | } |
288 | 288 | |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | * @param mixed $id the id for the service |
295 | 295 | * @return object the service instance if found |
296 | 296 | */ |
297 | - public function getService($id){ |
|
297 | + public function getService($id) { |
|
298 | 298 | return $this->getServiceProvider()->provideService($id); |
299 | 299 | } |
300 | 300 | |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | * @access public |
305 | 305 | * @return array registered services |
306 | 306 | */ |
307 | - public function getServices(){ |
|
307 | + public function getServices() { |
|
308 | 308 | return $this->getServiceProvider()->getServices(); |
309 | 309 | } |
310 | 310 | |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | * @param mixed $id the id for the service |
316 | 316 | * @return boolean wether service is registered |
317 | 317 | */ |
318 | - public function hasService($id){ |
|
318 | + public function hasService($id) { |
|
319 | 319 | return isset($this->services[$id]); |
320 | 320 | } |
321 | 321 | |
@@ -329,9 +329,9 @@ discard block |
||
329 | 329 | * @return object the service instance if found |
330 | 330 | * |
331 | 331 | */ |
332 | - protected function requestService($id){ |
|
332 | + protected function requestService($id) { |
|
333 | 333 | $service = $this->getService($id); |
334 | - if($service === NULL){ |
|
334 | + if ($service === NULL) { |
|
335 | 335 | throw new \RuntimeException('Service "'.$id.'" not found.'); |
336 | 336 | } |
337 | 337 | return $service; |
@@ -345,9 +345,9 @@ discard block |
||
345 | 345 | * @param object $config |
346 | 346 | * @return object the initialized service instance |
347 | 347 | */ |
348 | - protected function initService($config){ |
|
348 | + protected function initService($config) { |
|
349 | 349 | $id = trim((string)$config['id']); |
350 | - if($id != ''){ |
|
350 | + if ($id != '') { |
|
351 | 351 | return $this->services[$id] = $this->createService($config); |
352 | 352 | } |
353 | 353 | } |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | * @param $config |
360 | 360 | * @return object the initialized service instance |
361 | 361 | */ |
362 | - public function createService($config){ |
|
362 | + public function createService($config) { |
|
363 | 363 | return ServiceFactory::createService($config); |
364 | 364 | } |
365 | 365 | |
@@ -376,28 +376,28 @@ discard block |
||
376 | 376 | * @param object $config configuration to get the modification instructions from. |
377 | 377 | * @return object the modificated service |
378 | 378 | */ |
379 | - protected function modifyService($service, $config){ |
|
379 | + protected function modifyService($service, $config) { |
|
380 | 380 | // set instance properties |
381 | - if($config->property){ |
|
382 | - foreach($config->property as $property){ |
|
381 | + if ($config->property) { |
|
382 | + foreach ($config->property as $property) { |
|
383 | 383 | $arg = $this->buildArg($property); |
384 | - if($arg){ |
|
384 | + if ($arg) { |
|
385 | 385 | $setter = self::getSetter($property); |
386 | - if($setter && self::hasPublicProperty($service, 'Method', $setter)){ |
|
386 | + if ($setter && self::hasPublicProperty($service, 'Method', $setter)) { |
|
387 | 387 | $service->{$setter}($arg); |
388 | - }elseif(in_array($property, self::hasPublicProperty($service, 'Property', $setter))){ |
|
388 | + }elseif (in_array($property, self::hasPublicProperty($service, 'Property', $setter))) { |
|
389 | 389 | $service->$setter = $arg; |
390 | 390 | } |
391 | 391 | } |
392 | 392 | } |
393 | 393 | } |
394 | 394 | // call instance methods |
395 | - if($config->action){ |
|
396 | - foreach($config->action as $action){ |
|
395 | + if ($config->action) { |
|
396 | + foreach ($config->action as $action) { |
|
397 | 397 | $method = (string)$action['method'] != '' ? (string)$action['method'] : NULL; |
398 | - if($method && self::hasPublicProperty($service, 'Method', $method)){ |
|
398 | + if ($method && self::hasPublicProperty($service, 'Method', $method)) { |
|
399 | 399 | $args = array(); |
400 | - foreach($action->children() as $argument){ |
|
400 | + foreach ($action->children() as $argument) { |
|
401 | 401 | $args[] = $this->buildArg($argument); |
402 | 402 | } |
403 | 403 | call_user_func_array(array($service, (string)$action['method']), $args); |
@@ -405,9 +405,9 @@ discard block |
||
405 | 405 | } |
406 | 406 | } |
407 | 407 | // register instance listeners |
408 | - if($service instanceof \PEIP\INF\Event\Connectable){ |
|
409 | - if($config->listener){ |
|
410 | - foreach($config->listener as $listenerConf){ |
|
408 | + if ($service instanceof \PEIP\INF\Event\Connectable) { |
|
409 | + if ($config->listener) { |
|
410 | + foreach ($config->listener as $listenerConf) { |
|
411 | 411 | $event = (string)$listenerConf['event']; |
412 | 412 | $listener = $this->provideService($listenerConf); |
413 | 413 | $service->connect($event, $listener); |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | * @param mixed $id the id ofthe gateway |
427 | 427 | * @return object the gateway instance |
428 | 428 | */ |
429 | - public function getGateway($id){ |
|
429 | + public function getGateway($id) { |
|
430 | 430 | return $this->getServiceProvider()->provideService($id); |
431 | 431 | } |
432 | 432 | |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | * @param object $config configuration object for the pollable channel. |
439 | 439 | * @return \PEIP\INF\Channel\Channel the created pollable channel instance |
440 | 440 | */ |
441 | - public function createChannel($config){ |
|
441 | + public function createChannel($config) { |
|
442 | 442 | return $this->doCreateChannel($config, 'PollableChannel'); |
443 | 443 | } |
444 | 444 | |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | * @param object $config configuration object for the subscribable channel. |
451 | 451 | * @return \PEIP\INF\Channel\Channel the created subscribable channel instance |
452 | 452 | */ |
453 | - public function createSubscribableChannel($config){ |
|
453 | + public function createSubscribableChannel($config) { |
|
454 | 454 | return $this->doCreateChannel($config, 'PublishSubscribeChannel'); |
455 | 455 | } |
456 | 456 | |
@@ -463,9 +463,9 @@ discard block |
||
463 | 463 | * @param $additionalArguments additional arguments for the channel constructor (without first arg = id) |
464 | 464 | * @return \PEIP\INF\Channel\Channel the created channel instance |
465 | 465 | */ |
466 | - public function doCreateChannel($config, $defaultChannelClass, array $additionalArguments = array()){ |
|
466 | + public function doCreateChannel($config, $defaultChannelClass, array $additionalArguments = array()) { |
|
467 | 467 | $id = (string)$config['id']; |
468 | - if($id != ''){ |
|
468 | + if ($id != '') { |
|
469 | 469 | array_unshift($additionalArguments, $id); |
470 | 470 | $channel = $this->buildAndModify($config, $additionalArguments, $defaultChannelClass); |
471 | 471 | $this->channelRegistry->register($channel); |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | * @param string $defaultClass the class to use if none is set in config. |
483 | 483 | * @return object the gateway instance |
484 | 484 | */ |
485 | - public function createGateway($config, $defaultClass = false){ |
|
485 | + public function createGateway($config, $defaultClass = false) { |
|
486 | 486 | $args = array( |
487 | 487 | $this->getRequestChannel($config), |
488 | 488 | $this->getReplyChannel($config) |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | * @param string $defaultClass the class to use if none is set in config. |
507 | 507 | * @return object the router instance |
508 | 508 | */ |
509 | - public function createRouter($config, $defaultClass = false){ |
|
509 | + public function createRouter($config, $defaultClass = false) { |
|
510 | 510 | $resolver = $config['channel_resolver'] ? (string)$config['channel_resolver'] : $this->channelRegistry; |
511 | 511 | return $this->buildAndModify($config, array( |
512 | 512 | $resolver, |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | * @param object $config configuration object for the splitter. |
524 | 524 | * @return object the splitter instance |
525 | 525 | */ |
526 | - public function createSplitter($config){ |
|
526 | + public function createSplitter($config) { |
|
527 | 527 | return $this->createReplyMessageHandler($config); |
528 | 528 | } |
529 | 529 | |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | * @param object $config configuration object for the transformer. |
537 | 537 | * @return object the transformer instance |
538 | 538 | */ |
539 | - public function createTransformer($config){ |
|
539 | + public function createTransformer($config) { |
|
540 | 540 | return $this->createReplyMessageHandler($config); |
541 | 541 | } |
542 | 542 | |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | * @param object $config configuration object for the aggregator. |
550 | 550 | * @return object the aggregator instance |
551 | 551 | */ |
552 | - public function createAggregator($config){ |
|
552 | + public function createAggregator($config) { |
|
553 | 553 | return $this->createReplyMessageHandler($config); |
554 | 554 | } |
555 | 555 | |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | * @param object $config configuration object for the wiretap. |
563 | 563 | * @return object the wiretap instance |
564 | 564 | */ |
565 | - public function createWiretap($config){ |
|
565 | + public function createWiretap($config) { |
|
566 | 566 | return $this->createReplyMessageHandler($config, 'Wiretap'); |
567 | 567 | } |
568 | 568 | |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | * @param string $defaultClass the class to use if none is set in config. |
576 | 576 | * @return object the reply-message-handler instance |
577 | 577 | */ |
578 | - public function createReplyMessageHandler($config, $defaultClass = false){ |
|
578 | + public function createReplyMessageHandler($config, $defaultClass = false) { |
|
579 | 579 | return $this->buildAndModify($config, $this->getReplyHandlerArguments($config), $defaultClass); |
580 | 580 | } |
581 | 581 | |
@@ -588,12 +588,12 @@ discard block |
||
588 | 588 | * @param string $defaultClass the class to use if none is set in config. |
589 | 589 | * @return object the service-activator instance |
590 | 590 | */ |
591 | - public function createServiceActivator($config, $defaultClass = false){ |
|
591 | + public function createServiceActivator($config, $defaultClass = false) { |
|
592 | 592 | $method = (string)$config['method']; |
593 | 593 | $service = $this->getService((string)$config['ref']); |
594 | - if($method && $service){ |
|
594 | + if ($method && $service) { |
|
595 | 595 | $args = $this->getReplyHandlerArguments($config); |
596 | - array_unshift($args,array( |
|
596 | + array_unshift($args, array( |
|
597 | 597 | $service, |
598 | 598 | $method |
599 | 599 | )); |
@@ -614,11 +614,11 @@ discard block |
||
614 | 614 | * @param object $config configuration object for the service. |
615 | 615 | * @return |
616 | 616 | */ |
617 | - protected function provideService($config){ |
|
617 | + protected function provideService($config) { |
|
618 | 618 | $ref = trim((string)$config['ref']); |
619 | - if($ref != ''){ |
|
619 | + if ($ref != '') { |
|
620 | 620 | $service = $this->getService($ref); |
621 | - }else{ |
|
621 | + }else { |
|
622 | 622 | $service = $this->createService($config); |
623 | 623 | } |
624 | 624 | return $service; |
@@ -635,10 +635,10 @@ discard block |
||
635 | 635 | * @param object $config configuration object for the setter-method. |
636 | 636 | * @return string camel-cased |
637 | 637 | */ |
638 | - protected static function getSetter($config){ |
|
639 | - if($config['setter']){ |
|
638 | + protected static function getSetter($config) { |
|
639 | + if ($config['setter']) { |
|
640 | 640 | $setter = (string)$config['setter']; |
641 | - }elseif($config['name']){ |
|
641 | + }elseif ($config['name']) { |
|
642 | 642 | $setter = 'set'.ucfirst((string)$config['name']); |
643 | 643 | } |
644 | 644 | return $setter; |
@@ -651,29 +651,29 @@ discard block |
||
651 | 651 | * @param object $config configuration object to create argument from. |
652 | 652 | * @return mixed build argument |
653 | 653 | */ |
654 | - protected function buildArg($config){ |
|
655 | - if(trim((string)$config['value']) != ''){ |
|
654 | + protected function buildArg($config) { |
|
655 | + if (trim((string)$config['value']) != '') { |
|
656 | 656 | $arg = (string)$config['value']; |
657 | - }elseif($config->getName() == 'value'){ |
|
657 | + }elseif ($config->getName() == 'value') { |
|
658 | 658 | $arg = (string)$config; |
659 | - }elseif($config->getName() == 'list'){ |
|
659 | + }elseif ($config->getName() == 'list') { |
|
660 | 660 | $arg = array(); |
661 | - foreach($config->children() as $entry){ |
|
662 | - if($entry->getName() == 'value'){ |
|
663 | - if($entry['key']){ |
|
661 | + foreach ($config->children() as $entry) { |
|
662 | + if ($entry->getName() == 'value') { |
|
663 | + if ($entry['key']) { |
|
664 | 664 | $arg[(string)$entry['key']] = (string)$entry; |
665 | - }else{ |
|
665 | + }else { |
|
666 | 666 | $arg[] = (string)$entry; |
667 | 667 | } |
668 | - }elseif($entry->getName() == 'service'){ |
|
668 | + }elseif ($entry->getName() == 'service') { |
|
669 | 669 | $arg[] = $this->provideService($entry); |
670 | 670 | } |
671 | 671 | } |
672 | - }elseif($config->getName() == 'service'){ |
|
672 | + }elseif ($config->getName() == 'service') { |
|
673 | 673 | $arg = $this->provideService($config); |
674 | - }elseif($config->list){ |
|
674 | + }elseif ($config->list) { |
|
675 | 675 | $arg = $this->buildArg($config->list); |
676 | - }elseif($config->service){ |
|
676 | + }elseif ($config->service) { |
|
677 | 677 | $arg = $this->buildArg($config->service); |
678 | 678 | } |
679 | 679 | return $arg; |
@@ -687,12 +687,12 @@ discard block |
||
687 | 687 | * @param object $config configuration object to create arguments from. |
688 | 688 | * @return mixed build arguments |
689 | 689 | */ |
690 | - protected function getReplyHandlerArguments($config){ |
|
690 | + protected function getReplyHandlerArguments($config) { |
|
691 | 691 | $args = array( |
692 | 692 | $this->doGetChannel('input', $config), |
693 | 693 | $this->doGetChannel('output', $config) |
694 | 694 | ); |
695 | - if($args[0] == NULL){ |
|
695 | + if ($args[0] == NULL) { |
|
696 | 696 | throw new \RuntimeException('Could not receive input channel.'); |
697 | 697 | } |
698 | 698 | return $args; |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | * @param object $config configuration object to return request-channel from. |
708 | 708 | * @return \PEIP\INF\Channel\Channel request-channel |
709 | 709 | */ |
710 | - protected function getRequestChannel($config){ |
|
710 | + protected function getRequestChannel($config) { |
|
711 | 711 | return $this->doGetChannel('request', $config); |
712 | 712 | } |
713 | 713 | |
@@ -720,7 +720,7 @@ discard block |
||
720 | 720 | * @param object $config configuration object to return reply-channel from. |
721 | 721 | * @return \PEIP\INF\Channel\Channel reply-channel |
722 | 722 | */ |
723 | - protected function getReplyChannel($config){ |
|
723 | + protected function getReplyChannel($config) { |
|
724 | 724 | return $this->doGetChannel('reply', $config); |
725 | 725 | } |
726 | 726 | |
@@ -733,7 +733,7 @@ discard block |
||
733 | 733 | * @param object $config configuration object to return channel from. |
734 | 734 | * @return \PEIP\INF\Channel\Channel reply-channel |
735 | 735 | */ |
736 | - public function doGetChannel($type, $config){ |
|
736 | + public function doGetChannel($type, $config) { |
|
737 | 737 | $channelName = $config[$type."_channel"] |
738 | 738 | ? $config[$type."_channel"] |
739 | 739 | : $config["default_".$type."_channel"]; |
@@ -753,7 +753,7 @@ discard block |
||
753 | 753 | * @param string $defaultClass class to create instance for if none is set in config |
754 | 754 | * @return object build and modified srvice instance |
755 | 755 | */ |
756 | - public function buildAndModify($config, $arguments, $defaultClass = false){ |
|
756 | + public function buildAndModify($config, $arguments, $defaultClass = false) { |
|
757 | 757 | return ServiceFactory::buildAndModify($config, $arguments, $defaultClass); |
758 | 758 | } |
759 | 759 | |
@@ -767,21 +767,21 @@ discard block |
||
767 | 767 | * @param string $defaultClass class to create instance for if none is set in config |
768 | 768 | * @return object build and modified srvice instance |
769 | 769 | */ |
770 | - protected static function doBuild($config, $arguments, $defaultClass = false){ |
|
770 | + protected static function doBuild($config, $arguments, $defaultClass = false) { |
|
771 | 771 | $cls = $config["class"] ? trim((string)$config["class"]) : (string)$defaultClass; |
772 | - if($cls != ''){ |
|
772 | + if ($cls != '') { |
|
773 | 773 | try { |
774 | 774 | $constructor = (string)$config["constructor"]; |
775 | - if($constructor != ''){ |
|
775 | + if ($constructor != '') { |
|
776 | 776 | $service = call_user_func_array(array($cls, $constructor), $arguments); |
777 | - }else{ |
|
777 | + }else { |
|
778 | 778 | $service = self::build($cls, $arguments); |
779 | 779 | } |
780 | - }catch(\Exception $e){ |
|
780 | + } catch (\Exception $e) { |
|
781 | 781 | throw new \RuntimeException('Could not create Service "'.$cls.'" -> '.$e->getMessage()); |
782 | 782 | } |
783 | 783 | } |
784 | - if(is_object($service)){ |
|
784 | + if (is_object($service)) { |
|
785 | 785 | return $service; |
786 | 786 | } |
787 | 787 | throw new \RuntimeException('Could not create Service "'.$cls.'". Class does not exist.'); |
@@ -797,13 +797,13 @@ discard block |
||
797 | 797 | * @param array $arguments arguments for the constructor |
798 | 798 | * @return object build and modified srvice instance |
799 | 799 | */ |
800 | - protected static function build($className, $arguments){ |
|
800 | + protected static function build($className, $arguments) { |
|
801 | 801 | return GenericBuilder::getInstance($className)->build($arguments); |
802 | 802 | } |
803 | 803 | |
804 | - protected static function hasPublicProperty($service, $type, $name){ |
|
804 | + protected static function hasPublicProperty($service, $type, $name) { |
|
805 | 805 | $reflection = GenericBuilder::getInstance(get_class($service))->getReflectionClass(); |
806 | - if($reflection->{'has'.$type}($name) && $reflection->{'get'.$type}($name)->isPublic()){ |
|
806 | + if ($reflection->{'has'.$type}($name) && $reflection->{'get'.$type}($name)->isPublic()) { |
|
807 | 807 | return true; |
808 | 808 | } |
809 | 809 | return false; |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | public static function createFromFile($file){ |
95 | 95 | if(file_exists($file)){ |
96 | 96 | return self::createFromString(file_get_contents($file)); |
97 | - }else{ |
|
97 | + } else{ |
|
98 | 98 | throw new \RuntimeException('Cannot open file "'.$file.'".'); |
99 | 99 | } |
100 | 100 | } |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | $setter = self::getSetter($property); |
386 | 386 | if($setter && self::hasPublicProperty($service, 'Method', $setter)){ |
387 | 387 | $service->{$setter}($arg); |
388 | - }elseif(in_array($property, self::hasPublicProperty($service, 'Property', $setter))){ |
|
388 | + } elseif(in_array($property, self::hasPublicProperty($service, 'Property', $setter))){ |
|
389 | 389 | $service->$setter = $arg; |
390 | 390 | } |
391 | 391 | } |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | $ref = trim((string)$config['ref']); |
619 | 619 | if($ref != ''){ |
620 | 620 | $service = $this->getService($ref); |
621 | - }else{ |
|
621 | + } else{ |
|
622 | 622 | $service = $this->createService($config); |
623 | 623 | } |
624 | 624 | return $service; |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | protected static function getSetter($config){ |
639 | 639 | if($config['setter']){ |
640 | 640 | $setter = (string)$config['setter']; |
641 | - }elseif($config['name']){ |
|
641 | + } elseif($config['name']){ |
|
642 | 642 | $setter = 'set'.ucfirst((string)$config['name']); |
643 | 643 | } |
644 | 644 | return $setter; |
@@ -654,26 +654,26 @@ discard block |
||
654 | 654 | protected function buildArg($config){ |
655 | 655 | if(trim((string)$config['value']) != ''){ |
656 | 656 | $arg = (string)$config['value']; |
657 | - }elseif($config->getName() == 'value'){ |
|
657 | + } elseif($config->getName() == 'value'){ |
|
658 | 658 | $arg = (string)$config; |
659 | - }elseif($config->getName() == 'list'){ |
|
659 | + } elseif($config->getName() == 'list'){ |
|
660 | 660 | $arg = array(); |
661 | 661 | foreach($config->children() as $entry){ |
662 | 662 | if($entry->getName() == 'value'){ |
663 | 663 | if($entry['key']){ |
664 | 664 | $arg[(string)$entry['key']] = (string)$entry; |
665 | - }else{ |
|
665 | + } else{ |
|
666 | 666 | $arg[] = (string)$entry; |
667 | 667 | } |
668 | - }elseif($entry->getName() == 'service'){ |
|
668 | + } elseif($entry->getName() == 'service'){ |
|
669 | 669 | $arg[] = $this->provideService($entry); |
670 | 670 | } |
671 | 671 | } |
672 | - }elseif($config->getName() == 'service'){ |
|
672 | + } elseif($config->getName() == 'service'){ |
|
673 | 673 | $arg = $this->provideService($config); |
674 | - }elseif($config->list){ |
|
674 | + } elseif($config->list){ |
|
675 | 675 | $arg = $this->buildArg($config->list); |
676 | - }elseif($config->service){ |
|
676 | + } elseif($config->service){ |
|
677 | 677 | $arg = $this->buildArg($config->service); |
678 | 678 | } |
679 | 679 | return $arg; |
@@ -774,10 +774,10 @@ discard block |
||
774 | 774 | $constructor = (string)$config["constructor"]; |
775 | 775 | if($constructor != ''){ |
776 | 776 | $service = call_user_func_array(array($cls, $constructor), $arguments); |
777 | - }else{ |
|
777 | + } else{ |
|
778 | 778 | $service = self::build($cls, $arguments); |
779 | 779 | } |
780 | - }catch(\Exception $e){ |
|
780 | + } catch(\Exception $e){ |
|
781 | 781 | throw new \RuntimeException('Could not create Service "'.$cls.'" -> '.$e->getMessage()); |
782 | 782 | } |
783 | 783 | } |
@@ -71,7 +71,6 @@ |
||
71 | 71 | * notifies all listeners on a event on a subject |
72 | 72 | * |
73 | 73 | * @access public |
74 | - * @param string $name name of the event |
|
75 | 74 | * @param mixed $subject the subject |
76 | 75 | * @return |
77 | 76 | */ |
@@ -18,11 +18,11 @@ discard block |
||
18 | 18 | * @param Callable|PEIP\INF\Handler\Handler $listener listener to connect |
19 | 19 | * @return |
20 | 20 | */ |
21 | - public function connect($name, $listener){ |
|
21 | + public function connect($name, $listener) { |
|
22 | 22 | $name = is_object($name) ? get_class($name) : (string)$name; |
23 | - if(Test::assertClassOrInterfaceExists($name)){ |
|
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 | } |
@@ -35,10 +35,10 @@ discard block |
||
35 | 35 | * @param mixed $subject the subject |
36 | 36 | * @return |
37 | 37 | */ |
38 | - public function notify($name, $subject){ |
|
38 | + public function notify($name, $subject) { |
|
39 | 39 | $res = false; |
40 | - foreach(Reflection::getImplementedClassesAndInterfaces($name) as $cls){ |
|
41 | - if(parent::hasListeners($cls)){ |
|
40 | + foreach (Reflection::getImplementedClassesAndInterfaces($name) as $cls) { |
|
41 | + if (parent::hasListeners($cls)) { |
|
42 | 42 | self::doNotify($this->getListeners($cls), $subject); |
43 | 43 | $res = true; |
44 | 44 | } |
@@ -56,10 +56,10 @@ discard block |
||
56 | 56 | * @param mixed $subject the subject |
57 | 57 | * @return \PEIP\INF\Handler\Handler listener which returned a boolean true value |
58 | 58 | */ |
59 | - public function notifyUntil($name, $subject){ |
|
59 | + public function notifyUntil($name, $subject) { |
|
60 | 60 | $res = NULL; |
61 | - foreach(Reflection::getImplementedClassesAndInterfaces($name) as $cls){ |
|
62 | - if(!$res && parent::hasListeners($cls)){ |
|
61 | + foreach (Reflection::getImplementedClassesAndInterfaces($name) as $cls) { |
|
62 | + if (!$res && parent::hasListeners($cls)) { |
|
63 | 63 | $res = self::doNotifyUntil($this->getListeners($cls), $subject); |
64 | 64 | } |
65 | 65 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * @param mixed $subject the subject |
76 | 76 | * @return |
77 | 77 | */ |
78 | - public function notifyOfInstance($subject){ |
|
78 | + public function notifyOfInstance($subject) { |
|
79 | 79 | |
80 | 80 | return $this->notify(get_class($subject), $subject); |
81 | 81 | } |
@@ -86,9 +86,9 @@ discard block |
||
86 | 86 | * @param string $name name of the event |
87 | 87 | * @return boolean wether any listener is registered for event-name |
88 | 88 | */ |
89 | - public function hasListeners($name){ |
|
90 | - foreach(Reflection::getImplementedClassesAndInterfaces($name) as $cls){ |
|
91 | - if(parent::hasListeners($cls)){ |
|
89 | + public function hasListeners($name) { |
|
90 | + foreach (Reflection::getImplementedClassesAndInterfaces($name) as $cls) { |
|
91 | + if (parent::hasListeners($cls)) { |
|
92 | 92 | return true; |
93 | 93 | } |
94 | 94 | } |
@@ -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 | } |