@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @access public |
24 | 24 | * @param string $name name of the event |
25 | 25 | * @param \PEIP\INF\Event\Event $object an event object |
26 | - * @return boolean |
|
26 | + * @return boolean|null |
|
27 | 27 | */ |
28 | 28 | public function notify($name, $object){ |
29 | 29 | if($object instanceof \PEIP\INF\Event\Event){ |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * @param array $headers headers of the event-object as key/value pairs |
54 | 54 | * @param string $eventClass event-class to create instances from |
55 | 55 | * @return |
56 | - * @see EventBuilder |
|
56 | + boolean|null @see EventBuilder |
|
57 | 57 | */ |
58 | 58 | public function buildAndNotify($name, $object, array $headers = array(), $eventClass = false, $type = false){ |
59 | 59 | if(!$this->hasListeners($name, ($object))){ |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | $this->getListeners( |
33 | 33 | $name, |
34 | 34 | $object |
35 | - ), |
|
36 | - $object->getContent() |
|
37 | - ); |
|
35 | + ), |
|
36 | + $object->getContent() |
|
37 | + ); |
|
38 | 38 | }else{ |
39 | 39 | throw new \InvalidArgumentException('instance of \PEIP\INF\Event\Event must contain subject'); |
40 | 40 | } |
@@ -43,18 +43,18 @@ discard block |
||
43 | 43 | } |
44 | 44 | } //put your code here |
45 | 45 | |
46 | - /** |
|
47 | - * Creates an event-object with given object as content/subject and notifies |
|
48 | - * all registers listeners of the event. |
|
49 | - * |
|
50 | - * @access public |
|
51 | - * @param string $name name of the event |
|
52 | - * @param object $object the subject of the event |
|
53 | - * @param array $headers headers of the event-object as key/value pairs |
|
54 | - * @param string $eventClass event-class to create instances from |
|
55 | - * @return |
|
56 | - * @see EventBuilder |
|
57 | - */ |
|
46 | + /** |
|
47 | + * Creates an event-object with given object as content/subject and notifies |
|
48 | + * all registers listeners of the event. |
|
49 | + * |
|
50 | + * @access public |
|
51 | + * @param string $name name of the event |
|
52 | + * @param object $object the subject of the event |
|
53 | + * @param array $headers headers of the event-object as key/value pairs |
|
54 | + * @param string $eventClass event-class to create instances from |
|
55 | + * @return |
|
56 | + * @see EventBuilder |
|
57 | + */ |
|
58 | 58 | public function buildAndNotify($name, $object, array $headers = array(), $eventClass = false, $type = false){ |
59 | 59 | if(!$this->hasListeners($name, ($object))){ |
60 | 60 | return false; |
@@ -25,9 +25,9 @@ discard block |
||
25 | 25 | * @param \PEIP\INF\Event\Event $object an event object |
26 | 26 | * @return boolean |
27 | 27 | */ |
28 | - public function notify($name, $object){ |
|
29 | - if($object instanceof \PEIP\INF\Event\Event){ |
|
30 | - if(is_object($object->getContent())){ |
|
28 | + public function notify($name, $object) { |
|
29 | + if ($object instanceof \PEIP\INF\Event\Event) { |
|
30 | + if (is_object($object->getContent())) { |
|
31 | 31 | return self::doNotify( |
32 | 32 | $this->getListeners( |
33 | 33 | $name, |
@@ -35,10 +35,10 @@ discard block |
||
35 | 35 | ), |
36 | 36 | $object->getContent() |
37 | 37 | ); |
38 | - }else{ |
|
38 | + }else { |
|
39 | 39 | throw new \InvalidArgumentException('instance of \PEIP\INF\Event\Event must contain subject'); |
40 | 40 | } |
41 | - }else{ |
|
41 | + }else { |
|
42 | 42 | throw new \InvalidArgumentException('object must be instance of \PEIP\INF\Event\Event'); |
43 | 43 | } |
44 | 44 | } //put your code here |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | * @return |
56 | 56 | * @see EventBuilder |
57 | 57 | */ |
58 | - public function buildAndNotify($name, $object, array $headers = array(), $eventClass = false, $type = false){ |
|
59 | - if(!$this->hasListeners($name, ($object))){ |
|
58 | + public function buildAndNotify($name, $object, array $headers = array(), $eventClass = false, $type = false) { |
|
59 | + if (!$this->hasListeners($name, ($object))) { |
|
60 | 60 | return false; |
61 | 61 | } |
62 | 62 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * @param object $object object to check for listeners |
80 | 80 | * @return boolean |
81 | 81 | */ |
82 | - public function hasListeners($name, $object){ |
|
82 | + public function hasListeners($name, $object) { |
|
83 | 83 | return parent::hasListeners( |
84 | 84 | $name, |
85 | 85 | ReflectionPool::getInstance($object) |
@@ -46,10 +46,10 @@ |
||
46 | 46 | if($this->hasListeners($name, $object->getContent())){ |
47 | 47 | return self::doNotify($this->getListeners($name, $object->getContent()), $object); |
48 | 48 | } |
49 | - }else{ |
|
49 | + } else{ |
|
50 | 50 | throw new \InvalidArgumentException('instance of \PEIP\INF\Event\Event must contain subject'); |
51 | 51 | } |
52 | - }else{ |
|
52 | + } else{ |
|
53 | 53 | throw new \InvalidArgumentException('object must be instance of \PEIP\INF\Event\Event'); |
54 | 54 | } |
55 | 55 | } |
@@ -38,7 +38,7 @@ |
||
38 | 38 | * @access public |
39 | 39 | * @param string $name name of the event |
40 | 40 | * @param \PEIP\INF\Event\Event $object an event object |
41 | - * @return boolean |
|
41 | + * @return boolean|null |
|
42 | 42 | */ |
43 | 43 | public function notify($name, $object){ |
44 | 44 | if($object instanceof \PEIP\INF\Event\Event){ |
@@ -40,16 +40,16 @@ discard block |
||
40 | 40 | * @param \PEIP\INF\Event\Event $object an event object |
41 | 41 | * @return boolean |
42 | 42 | */ |
43 | - public function notify($name, $object){ |
|
44 | - if($object instanceof \PEIP\INF\Event\Event){ |
|
45 | - if(is_object($object->getContent())){ |
|
46 | - if($this->hasListeners($name, $object->getContent())){ |
|
43 | + public function notify($name, $object) { |
|
44 | + if ($object instanceof \PEIP\INF\Event\Event) { |
|
45 | + if (is_object($object->getContent())) { |
|
46 | + if ($this->hasListeners($name, $object->getContent())) { |
|
47 | 47 | return self::doNotify($this->getListeners($name, $object->getContent()), $object); |
48 | 48 | } |
49 | - }else{ |
|
49 | + }else { |
|
50 | 50 | throw new \InvalidArgumentException('instance of \PEIP\INF\Event\Event must contain subject'); |
51 | 51 | } |
52 | - }else{ |
|
52 | + }else { |
|
53 | 53 | throw new \InvalidArgumentException('object must be instance of \PEIP\INF\Event\Event'); |
54 | 54 | } |
55 | 55 | } |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | * @return |
67 | 67 | * @see EventBuilder |
68 | 68 | */ |
69 | - public function buildAndNotify($name, $object, array $headers = array(), $eventClass = false, $type = false){ |
|
70 | - if(!$this->hasListeners($name, $object)){ |
|
69 | + public function buildAndNotify($name, $object, array $headers = array(), $eventClass = false, $type = false) { |
|
70 | + if (!$this->hasListeners($name, $object)) { |
|
71 | 71 | return false; |
72 | 72 | } |
73 | 73 | $event = EventBuilder::getInstance($eventClass)->build( |
@@ -46,10 +46,10 @@ |
||
46 | 46 | if($this->hasListeners($name, $object->getContent())){ |
47 | 47 | return self::doNotify($this->getListeners($name, $object->getContent()), $object); |
48 | 48 | } |
49 | - }else{ |
|
49 | + } else{ |
|
50 | 50 | throw new \InvalidArgumentException('instance of \PEIP\INF\Event\Event must contain subject'); |
51 | 51 | } |
52 | - }else{ |
|
52 | + } else{ |
|
53 | 53 | throw new \InvalidArgumentException('object must be instance of \PEIP\INF\Event\Event'); |
54 | 54 | } |
55 | 55 | } |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | * @access public |
163 | 163 | * @param $name |
164 | 164 | * @param $subject |
165 | - * @return mixed |
|
165 | + * @return \PEIP\INF\Handler\Handler |
|
166 | 166 | */ |
167 | 167 | public function notifyUntil($name, $subject){ |
168 | 168 | if($this->hasListeners($name, $subject)){ |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | * @access protected |
206 | 206 | * @param $name |
207 | 207 | * @param $object |
208 | - * @return boolean |
|
208 | + * @return boolean|null |
|
209 | 209 | */ |
210 | 210 | protected static function doNotify(array $listeners, $subject){ |
211 | 211 | foreach($listeners as $listener){ |
@@ -209,11 +209,11 @@ |
||
209 | 209 | */ |
210 | 210 | protected static function doNotify(array $listeners, $subject){ |
211 | 211 | foreach($listeners as $listener){ |
212 | - if($listener instanceof \PEIP\INF\Handler\Handler){ |
|
212 | + if($listener instanceof \PEIP\INF\Handler\Handler){ |
|
213 | 213 | $listener->handle($subject); |
214 | - }elseif(is_callable($listener)){ |
|
215 | - call_user_func($listener, $subject); |
|
216 | - } |
|
214 | + }elseif(is_callable($listener)){ |
|
215 | + call_user_func($listener, $subject); |
|
216 | + } |
|
217 | 217 | } |
218 | 218 | } |
219 | 219 |
@@ -43,13 +43,13 @@ discard block |
||
43 | 43 | * @param Callable|PEIP\INF\Handler\Handler $listener event-handler |
44 | 44 | * @return boolean |
45 | 45 | */ |
46 | - public function connect($name, $object, $listener){ |
|
46 | + public function connect($name, $object, $listener) { |
|
47 | 47 | Test::ensureHandler($listener); |
48 | 48 | $listners = $this->doGetListeners(); |
49 | - if (!$this->listeners->contains($object)){ |
|
49 | + if (!$this->listeners->contains($object)) { |
|
50 | 50 | $this->listeners->attach($object, new \ArrayObject); |
51 | 51 | } |
52 | - if (!array_key_exists($name, $listners[$object])){ |
|
52 | + if (!array_key_exists($name, $listners[$object])) { |
|
53 | 53 | $this->listeners[$object][$name] = array(); |
54 | 54 | } |
55 | 55 | $hash = $this->getListenerHash($listener); |
@@ -67,14 +67,14 @@ discard block |
||
67 | 67 | * @param \PEIP\INF\Handler\Handler $listener event-handler |
68 | 68 | * @return boolean |
69 | 69 | */ |
70 | - public function disconnect($name, $object, $listener){ |
|
70 | + public function disconnect($name, $object, $listener) { |
|
71 | 71 | $listners = $this->doGetListeners(); |
72 | - if (!$listners->contains($object) || !isset($listners[$object][$name])){ |
|
72 | + if (!$listners->contains($object) || !isset($listners[$object][$name])) { |
|
73 | 73 | return false; |
74 | 74 | } |
75 | 75 | $eventListeners = $listners[$object][$name]; |
76 | 76 | $hash = $this->getListenerHash($listener); |
77 | - if(isset($eventListeners[$hash])){ |
|
77 | + if (isset($eventListeners[$hash])) { |
|
78 | 78 | unset($eventListeners[$hash]); |
79 | 79 | |
80 | 80 | $listners[$object][$name] = $eventListeners; |
@@ -83,10 +83,10 @@ discard block |
||
83 | 83 | return false; |
84 | 84 | } |
85 | 85 | |
86 | - public function disconnectAll($name, $object){ |
|
87 | - if(is_object($object)){ |
|
86 | + public function disconnectAll($name, $object) { |
|
87 | + if (is_object($object)) { |
|
88 | 88 | $listners = $this->doGetListeners(); |
89 | - if($listners && $this->hadListeners($name, $object)){ |
|
89 | + if ($listners && $this->hadListeners($name, $object)) { |
|
90 | 90 | $listners[$object][$name] = array(); |
91 | 91 | } |
92 | 92 | } |
@@ -100,13 +100,13 @@ discard block |
||
100 | 100 | * @param object $object object to check for listeners |
101 | 101 | * @return boolean |
102 | 102 | */ |
103 | - public function hasListeners($name, $object){ |
|
103 | + public function hasListeners($name, $object) { |
|
104 | 104 | $listners = $this->doGetListeners(); |
105 | - if (!$this->hadListeners($name, $object)){ |
|
105 | + if (!$this->hadListeners($name, $object)) { |
|
106 | 106 | $res = false; |
107 | - }else{ |
|
107 | + }else { |
|
108 | 108 | $listners = $this->doGetListeners(); |
109 | - $res = (boolean) count($listners[$object][$name]); |
|
109 | + $res = (boolean)count($listners[$object][$name]); |
|
110 | 110 | } |
111 | 111 | return $res; |
112 | 112 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * @param object $object object to check for listeners |
120 | 120 | * @return boolean |
121 | 121 | */ |
122 | - public function hadListeners($name, $object){ |
|
122 | + public function hadListeners($name, $object) { |
|
123 | 123 | $listners = $this->doGetListeners(); |
124 | 124 | return ($listners->contains($object) && isset($listners[$object][$name])) ? true : false; |
125 | 125 | } |
@@ -131,9 +131,9 @@ discard block |
||
131 | 131 | * @param object $object object to get event-names for |
132 | 132 | * @return string[] array of event-names |
133 | 133 | */ |
134 | - public function getEventNames($object){ |
|
134 | + public function getEventNames($object) { |
|
135 | 135 | $listeners = $this->doGetListeners(); |
136 | - if (!$listeners->contains($object)){ |
|
136 | + if (!$listeners->contains($object)) { |
|
137 | 137 | return array(); |
138 | 138 | } |
139 | 139 | return array_keys($listeners[$object]->getArrayCopy()); |
@@ -147,8 +147,8 @@ discard block |
||
147 | 147 | * @param $object |
148 | 148 | * @return boolean |
149 | 149 | */ |
150 | - public function notify($name, $object){ |
|
151 | - if($this->hasListeners($name, $object)){ |
|
150 | + public function notify($name, $object) { |
|
151 | + if ($this->hasListeners($name, $object)) { |
|
152 | 152 | $listners = $this->doGetListeners(); |
153 | 153 | self::doNotify($listners[$object][$name], $object); |
154 | 154 | } |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | * @param $subject |
165 | 165 | * @return mixed |
166 | 166 | */ |
167 | - public function notifyUntil($name, $subject){ |
|
168 | - if($this->hasListeners($name, $subject)){ |
|
167 | + public function notifyUntil($name, $subject) { |
|
168 | + if ($this->hasListeners($name, $subject)) { |
|
169 | 169 | $res = self::doNotifyUntil($this->getListeners($name, $subject), $subject); |
170 | 170 | } |
171 | 171 | return $res; |
@@ -179,8 +179,8 @@ discard block |
||
179 | 179 | * @param object $object object to check for listeners |
180 | 180 | * @return array array of listeners |
181 | 181 | */ |
182 | - public function getListeners($name, $object){ |
|
183 | - if (!$this->hadListeners($name, $object)){ |
|
182 | + public function getListeners($name, $object) { |
|
183 | + if (!$this->hadListeners($name, $object)) { |
|
184 | 184 | return array(); |
185 | 185 | } |
186 | 186 | $listeners = $this->listeners[$object]->getArrayCopy(); |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | * @access protected |
195 | 195 | * @return ObjectStorage |
196 | 196 | */ |
197 | - protected function doGetListeners(){ |
|
197 | + protected function doGetListeners() { |
|
198 | 198 | return isset($this->listeners) ? $this->listeners : $this->listeners = new ObjectStorage(); |
199 | 199 | } |
200 | 200 | |
@@ -207,11 +207,11 @@ discard block |
||
207 | 207 | * @param $object |
208 | 208 | * @return boolean |
209 | 209 | */ |
210 | - protected static function doNotify(array $listeners, $subject){ |
|
211 | - foreach($listeners as $listener){ |
|
212 | - if($listener instanceof \PEIP\INF\Handler\Handler){ |
|
210 | + protected static function doNotify(array $listeners, $subject) { |
|
211 | + foreach ($listeners as $listener) { |
|
212 | + if ($listener instanceof \PEIP\INF\Handler\Handler) { |
|
213 | 213 | $listener->handle($subject); |
214 | - }elseif(is_callable($listener)){ |
|
214 | + }elseif (is_callable($listener)) { |
|
215 | 215 | call_user_func($listener, $subject); |
216 | 216 | } |
217 | 217 | } |
@@ -226,12 +226,12 @@ discard block |
||
226 | 226 | * @param $object |
227 | 227 | * @return \PEIP\INF\Handler\Handler the listener which returned a boolean true value |
228 | 228 | */ |
229 | - protected static function doNotifyUntil(array $listeners, $subject){ |
|
229 | + protected static function doNotifyUntil(array $listeners, $subject) { |
|
230 | 230 | $res = NULL; |
231 | - foreach ($listeners as $listener){ |
|
232 | - if($listener instanceof \PEIP\INF\Handler\Handler){ |
|
231 | + foreach ($listeners as $listener) { |
|
232 | + if ($listener instanceof \PEIP\INF\Handler\Handler) { |
|
233 | 233 | $res = $listener->handle($subject); |
234 | - if ($res){ |
|
234 | + if ($res) { |
|
235 | 235 | return $listener; |
236 | 236 | } |
237 | 237 | } |
@@ -239,8 +239,8 @@ discard block |
||
239 | 239 | return $res; |
240 | 240 | } |
241 | 241 | |
242 | - protected function getListenerHash($listener){ |
|
243 | - if(!is_object($listener)){ |
|
242 | + protected function getListenerHash($listener) { |
|
243 | + if (!is_object($listener)) { |
|
244 | 244 | $o = new \stdClass(); |
245 | 245 | $o->listener = $listener; |
246 | 246 | $listener = $o; |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | $listners = $this->doGetListeners(); |
105 | 105 | if (!$this->hadListeners($name, $object)){ |
106 | 106 | $res = false; |
107 | - }else{ |
|
107 | + } else{ |
|
108 | 108 | $listners = $this->doGetListeners(); |
109 | 109 | $res = (boolean) count($listners[$object][$name]); |
110 | 110 | } |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | foreach($listeners as $listener){ |
212 | 212 | if($listener instanceof \PEIP\INF\Handler\Handler){ |
213 | 213 | $listener->handle($subject); |
214 | - }elseif(is_callable($listener)){ |
|
214 | + } elseif(is_callable($listener)){ |
|
215 | 215 | call_user_func($listener, $subject); |
216 | 216 | } |
217 | 217 | } |
@@ -49,7 +49,6 @@ |
||
49 | 49 | * @access public |
50 | 50 | * @param mixed $subject the subject for the event |
51 | 51 | * @param string $name the name of the event |
52 | - * @param array|ArrayAccess $headers the headers for the event |
|
53 | 52 | */ |
54 | 53 | public function __construct($subject, $name, $parameters = array(), $type = false){ |
55 | 54 | parent::__construct($subject, Test::ensureArrayAccess($parameters)); |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * @param string $name the name of the event |
52 | 52 | * @param array|ArrayAccess $headers the headers for the event |
53 | 53 | */ |
54 | - public function __construct($subject, $name, $parameters = array(), $type = false){ |
|
54 | + public function __construct($subject, $name, $parameters = array(), $type = false) { |
|
55 | 55 | parent::__construct($subject, Test::ensureArrayAccess($parameters)); |
56 | 56 | $this->name = $name; |
57 | 57 | $this->type = $type ? $type : get_class($this); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @access public |
64 | 64 | * @return string the name of the event |
65 | 65 | */ |
66 | - public function getName(){ |
|
66 | + public function getName() { |
|
67 | 67 | return $this->name; |
68 | 68 | } |
69 | 69 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @access public |
75 | 75 | * @return string the type of the event |
76 | 76 | */ |
77 | - public function getType(){ |
|
77 | + public function getType() { |
|
78 | 78 | return $this->name; |
79 | 79 | } |
80 | 80 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @access public |
85 | 85 | * @param mixed $value the return-value to set |
86 | 86 | */ |
87 | - public function setReturnValue($value){ |
|
87 | + public function setReturnValue($value) { |
|
88 | 88 | $this->value = $value; |
89 | 89 | } |
90 | 90 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * @access public |
95 | 95 | * @return mixed the return-value to set |
96 | 96 | */ |
97 | - public function getReturnValue(){ |
|
97 | + public function getReturnValue() { |
|
98 | 98 | return $this->value; |
99 | 99 | } |
100 | 100 | |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | * @access public |
105 | 105 | * @param boolean $processed |
106 | 106 | */ |
107 | - public function setProcessed($processed){ |
|
108 | - $this->processed = (boolean) $processed; |
|
107 | + public function setProcessed($processed) { |
|
108 | + $this->processed = (boolean)$processed; |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * @access public |
115 | 115 | * @return boolean wether the event is processed |
116 | 116 | */ |
117 | - public function isProcessed(){ |
|
117 | + public function isProcessed() { |
|
118 | 118 | return $this->processed; |
119 | 119 | } |
120 | 120 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * @access public |
125 | 125 | * @return mixed the subject/content |
126 | 126 | */ |
127 | - public function getSubject(){ |
|
127 | + public function getSubject() { |
|
128 | 128 | return $this->getContent(); |
129 | 129 | } |
130 | 130 | } |
@@ -55,7 +55,6 @@ discard block |
||
55 | 55 | * sets the channel to send requests from the gateway |
56 | 56 | * |
57 | 57 | * @access public |
58 | - * @param \PEIP\INF\Channel\Channel $replyChannel The default channel to receive requests from the gateway |
|
59 | 58 | * @return |
60 | 59 | */ |
61 | 60 | public function setRequestChannel(\PEIP\INF\Channel\Channel $requestChannel){ |
@@ -108,7 +107,7 @@ discard block |
||
108 | 107 | * sends and receives a request/message through the gateway |
109 | 108 | * |
110 | 109 | * @access public |
111 | - * @param mixed $content the content/payload for the message to send |
|
110 | + * @param \Order $content the content/payload for the message to send |
|
112 | 111 | * @return mixed content/payload of the received message |
113 | 112 | */ |
114 | 113 | public function sendAndReceive($content){ |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | * @param \PEIP\INF\Channel\PollableChannel $replyChannel The default channel to receive requests from the gateway |
43 | 43 | * @param array $defaultHeaders The default headers to apply to request messages |
44 | 44 | */ |
45 | - public function __construct(\PEIP\INF\Channel\Channel $requestChannel, \PEIP\INF\Channel\Channel $replyChannel = NULL, array $defaultHeaders = array()){ |
|
45 | + public function __construct(\PEIP\INF\Channel\Channel $requestChannel, \PEIP\INF\Channel\Channel $replyChannel = NULL, array $defaultHeaders = array()) { |
|
46 | 46 | $this->setRequestChannel($requestChannel); |
47 | - if($replyChannel){ |
|
47 | + if ($replyChannel) { |
|
48 | 48 | $this->setReplyChannel($replyChannel); |
49 | 49 | } |
50 | 50 | $this->defaultHeaders = $defaultHeaders; |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * @param \PEIP\INF\Channel\Channel $replyChannel The default channel to receive requests from the gateway |
59 | 59 | * @return |
60 | 60 | */ |
61 | - public function setRequestChannel(\PEIP\INF\Channel\Channel $requestChannel){ |
|
61 | + public function setRequestChannel(\PEIP\INF\Channel\Channel $requestChannel) { |
|
62 | 62 | $this->requestChannel = $requestChannel; |
63 | 63 | } |
64 | 64 | |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | * @param \PEIP\INF\Channel\PollableChannel $replyChannel The default channel to receive requests from the gateway |
70 | 70 | * @return |
71 | 71 | */ |
72 | - public function setReplyChannel(\PEIP\INF\Channel\Channel $replyChannel){ |
|
73 | - if(!($replyChannel instanceof \PEIP\INF\Channel\PollableChannel)){ |
|
72 | + public function setReplyChannel(\PEIP\INF\Channel\Channel $replyChannel) { |
|
73 | + if (!($replyChannel instanceof \PEIP\INF\Channel\PollableChannel)) { |
|
74 | 74 | throw new \InvalidArgumentException('reply channel must be instance of \PEIP\INF\Channel\PollableChannel.'); |
75 | 75 | } |
76 | 76 | $this->replyChannel = $replyChannel; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * @param mixed $content the content/payload for the message to send |
84 | 84 | * @return |
85 | 85 | */ |
86 | - public function send($content){ |
|
86 | + public function send($content) { |
|
87 | 87 | return $this->requestChannel->send($this->buildMessage($content)); |
88 | 88 | } |
89 | 89 | |
@@ -93,12 +93,12 @@ discard block |
||
93 | 93 | * @access public |
94 | 94 | * @return mixed content/payload of the received message |
95 | 95 | */ |
96 | - public function receive(){ |
|
97 | - if(!isset($this->replyChannel)){ |
|
96 | + public function receive() { |
|
97 | + if (!isset($this->replyChannel)) { |
|
98 | 98 | throw new \LogicException('No replyChannel set.'); |
99 | 99 | } |
100 | 100 | $message = $this->replyChannel->receive(); |
101 | - if($message){ |
|
101 | + if ($message) { |
|
102 | 102 | return $message->getContent(); |
103 | 103 | } |
104 | 104 | return NULL; |
@@ -111,12 +111,12 @@ discard block |
||
111 | 111 | * @param mixed $content the content/payload for the message to send |
112 | 112 | * @return mixed content/payload of the received message |
113 | 113 | */ |
114 | - public function sendAndReceive($content){ |
|
114 | + public function sendAndReceive($content) { |
|
115 | 115 | $this->send($content); |
116 | 116 | try { |
117 | 117 | $res = $this->receive(); |
118 | 118 | } |
119 | - catch(\Exception $e){ |
|
119 | + catch (\Exception $e) { |
|
120 | 120 | return NULL; |
121 | 121 | } |
122 | 122 | return $res; |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * @param mixed $content the content/payload for the message to send |
130 | 130 | * @return \PEIP\INF\Message\Message the built message |
131 | 131 | */ |
132 | - protected function buildMessage($content){ |
|
132 | + protected function buildMessage($content) { |
|
133 | 133 | return $this->getMessageBuilder()->setContent($content)->build(); |
134 | 134 | } |
135 | 135 | |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | * @access protected |
140 | 140 | * @return MessageBuilder message builder instance for the registerd message class |
141 | 141 | */ |
142 | - protected function getMessageBuilder(){ |
|
142 | + protected function getMessageBuilder() { |
|
143 | 143 | return isset($this->messageBuilder) && ($this->messageBuilder->getMessageClass() == $this->getMessageClass()) |
144 | 144 | ? $this->messageBuilder |
145 | 145 | : $this->messageBuilder = MessageBuilder::getInstance($this->messageClass)->setHeaders($this->defaultHeaders); |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * @param string $messageClass message class to create instances from |
153 | 153 | * @return |
154 | 154 | */ |
155 | - public function setMessageClass($messageClass){ |
|
155 | + public function setMessageClass($messageClass) { |
|
156 | 156 | $this->messageClass = $messageClass; |
157 | 157 | } |
158 | 158 | |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | * @access public |
163 | 163 | * @return string message class to create instances from |
164 | 164 | */ |
165 | - public function getMessageClass(){ |
|
165 | + public function getMessageClass() { |
|
166 | 166 | return $this->messageClass; |
167 | 167 | } |
168 | 168 |
@@ -115,8 +115,7 @@ |
||
115 | 115 | $this->send($content); |
116 | 116 | try { |
117 | 117 | $res = $this->receive(); |
118 | - } |
|
119 | - catch(\Exception $e){ |
|
118 | + } catch(\Exception $e){ |
|
120 | 119 | return NULL; |
121 | 120 | } |
122 | 121 | return $res; |
@@ -33,10 +33,10 @@ |
||
33 | 33 | * Send a message, blocking until either the message is accepted or the |
34 | 34 | * specified timeout period elapses. |
35 | 35 | * |
36 | - * @param message the {@link Message} to send |
|
37 | - * @param timeout the timeout in milliseconds |
|
36 | + * @param message \PEIP\INF\Message\Message {@link Message} to send |
|
37 | + * @param timeout integer timeout in milliseconds |
|
38 | 38 | * |
39 | - * @return <code>true</code> if the message is sent successfully, |
|
39 | + * @return null|boolean if the message is sent successfully, |
|
40 | 40 | * <code>false</false> if the specified timeout period elapses or |
41 | 41 | * the send is interrupted |
42 | 42 | */ |
@@ -64,7 +64,6 @@ |
||
64 | 64 | * @static |
65 | 65 | * @access public |
66 | 66 | * @implements \PEIP\INF\Base\Buildable |
67 | - * @param string $name the name of the header |
|
68 | 67 | * @return boolean wether the header is set |
69 | 68 | */ |
70 | 69 | public static function build(array $arguments = array()){ |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @param $title |
35 | 35 | * @return |
36 | 36 | */ |
37 | - public function __construct($content, $title){ |
|
37 | + public function __construct($content, $title) { |
|
38 | 38 | $this->setContent((string)$content); |
39 | 39 | } |
40 | 40 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @param $title |
45 | 45 | * @return |
46 | 46 | */ |
47 | - public function setTitle($title){ |
|
47 | + public function setTitle($title) { |
|
48 | 48 | $this->title = (string)$title; |
49 | 49 | } |
50 | 50 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * @access public |
54 | 54 | * @return |
55 | 55 | */ |
56 | - public function getTitle(){ |
|
56 | + public function getTitle() { |
|
57 | 57 | return $this->title; |
58 | 58 | } |
59 | 59 | |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @param string $name the name of the header |
68 | 68 | * @return boolean wether the header is set |
69 | 69 | */ |
70 | - public static function build(array $arguments = array()){ |
|
70 | + public static function build(array $arguments = array()) { |
|
71 | 71 | return GenericBuilder::getInstance('\PEIP\Message\StringMessage')->build($arguments); |
72 | 72 | } |
73 | 73 |
@@ -42,7 +42,7 @@ |
||
42 | 42 | |
43 | 43 | /** |
44 | 44 | * @access public |
45 | - * @param $eventName |
|
45 | + * @param string $eventName |
|
46 | 46 | * @return |
47 | 47 | */ |
48 | 48 | public function setEventName($eventName){ |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | * @param $inputChannel |
32 | 32 | * @return |
33 | 33 | */ |
34 | - public function setInputChannel(\PEIP\INF\Channel\Channel $inputChannel){ |
|
35 | - if(isset($this->eventName)){ |
|
34 | + public function setInputChannel(\PEIP\INF\Channel\Channel $inputChannel) { |
|
35 | + if (isset($this->eventName)) { |
|
36 | 36 | $this->connectChannel($inputChannel); |
37 | - }else{ |
|
37 | + }else { |
|
38 | 38 | $this->inputChannel = $inputChannel; |
39 | 39 | } |
40 | 40 | } |
@@ -45,10 +45,10 @@ discard block |
||
45 | 45 | * @param $eventName |
46 | 46 | * @return |
47 | 47 | */ |
48 | - public function setEventName($eventName){ |
|
49 | - if(!isset($this->eventName)){ |
|
48 | + public function setEventName($eventName) { |
|
49 | + if (!isset($this->eventName)) { |
|
50 | 50 | $this->eventName = $eventName; |
51 | - if($this->inputChannel){ |
|
51 | + if ($this->inputChannel) { |
|
52 | 52 | $this->inputChannel->connect($this->eventName, $this); |
53 | 53 | } |
54 | 54 | } |
@@ -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 | } |
@@ -184,7 +184,7 @@ |
||
184 | 184 | |
185 | 185 | /** |
186 | 186 | * @access protected |
187 | - * @param $commandName |
|
187 | + * @param string $commandName |
|
188 | 188 | * @param $callable |
189 | 189 | * @return |
190 | 190 | */ |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @param $name |
61 | 61 | * @return |
62 | 62 | */ |
63 | - public function setName($name){ |
|
63 | + public function setName($name) { |
|
64 | 64 | $this->name = $name; |
65 | 65 | } |
66 | 66 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @access public |
70 | 70 | * @return |
71 | 71 | */ |
72 | - public function getName(){ |
|
72 | + public function getName() { |
|
73 | 73 | return $this->name; |
74 | 74 | } |
75 | 75 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * @param $timeout |
81 | 81 | * @return |
82 | 82 | */ |
83 | - public function send(\PEIP\INF\Message\Message $message, $timeout = -1){ |
|
83 | + public function send(\PEIP\INF\Message\Message $message, $timeout = -1) { |
|
84 | 84 | return $this->handle($message); |
85 | 85 | } |
86 | 86 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param $message |
91 | 91 | * @return |
92 | 92 | */ |
93 | - protected function doSend(\PEIP\INF\Message\Message $message){ |
|
93 | + protected function doSend(\PEIP\INF\Message\Message $message) { |
|
94 | 94 | $this->doFireEvent(self::EVENT_PRE_PUBLISH, array(self::HEADER_MESSAGE=>$message)); |
95 | 95 | $this->getMessageDispatcher()->notify($message); |
96 | 96 | $this->doFireEvent(self::EVENT_POST_PUBLISH, array(self::HEADER_MESSAGE=>$message)); |
@@ -103,12 +103,12 @@ discard block |
||
103 | 103 | * @param $content |
104 | 104 | * @return |
105 | 105 | */ |
106 | - protected function replyMessage($message){ |
|
106 | + protected function replyMessage($message) { |
|
107 | 107 | $message = $this->ensureMessage($message); |
108 | 108 | //if(\PEIP\Util\Test::assertMessage($message)){ |
109 | - if($this->getOutputChannel()){ |
|
109 | + if ($this->getOutputChannel()) { |
|
110 | 110 | $this->getOutputChannel()->send($message); |
111 | - }else{ |
|
111 | + }else { |
|
112 | 112 | $this->doSend($message); |
113 | 113 | } |
114 | 114 | //} |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | * @param $message |
121 | 121 | * @return |
122 | 122 | */ |
123 | - protected function doReply(\PEIP\INF\Message\Message $message){ |
|
123 | + protected function doReply(\PEIP\INF\Message\Message $message) { |
|
124 | 124 | $this->replyMessage($message); |
125 | 125 | } |
126 | 126 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * @param $handler |
131 | 131 | * @return |
132 | 132 | */ |
133 | - public function subscribe($handler){ |
|
133 | + public function subscribe($handler) { |
|
134 | 134 | Test::ensureHandler($handler); |
135 | 135 | $this->getMessageDispatcher()->connect($handler); |
136 | 136 | $this->doFireEvent(self::EVENT_SUBSCRIBE, array(self::HEADER_SUBSCRIBER=>$handler)); |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * @param $handler e |
143 | 143 | * @return |
144 | 144 | */ |
145 | - public function unsubscribe($handler){ |
|
145 | + public function unsubscribe($handler) { |
|
146 | 146 | Test::ensureHandler($handler); |
147 | 147 | $this->getMessageDispatcher()->disconnect($handler); |
148 | 148 | $this->doFireEvent( |
@@ -160,9 +160,9 @@ discard block |
||
160 | 160 | * @param $transferListeners |
161 | 161 | * @return |
162 | 162 | */ |
163 | - public function setMessageDispatcher(\PEIP\INF\Dispatcher\Dispatcher $dispatcher, $transferListeners = true){ |
|
164 | - if(isset($this->dispatcher) && $transferListeners){ |
|
165 | - foreach($this->dispatcher->getListeners() as $listener){ |
|
163 | + public function setMessageDispatcher(\PEIP\INF\Dispatcher\Dispatcher $dispatcher, $transferListeners = true) { |
|
164 | + if (isset($this->dispatcher) && $transferListeners) { |
|
165 | + foreach ($this->dispatcher->getListeners() as $listener) { |
|
166 | 166 | $dispatcher->connect($listener); |
167 | 167 | $this->dispatcher->disconnect($listener); |
168 | 168 | } |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | * @access public |
177 | 177 | * @return |
178 | 178 | */ |
179 | - public function getMessageDispatcher(){ |
|
179 | + public function getMessageDispatcher() { |
|
180 | 180 | $defaultDispatcher = self::DEFAULT_CLASS_MESSAGE_DISPATCHER; |
181 | 181 | return isset($this->dispatcher) ? $this->dispatcher : $this->dispatcher = new $defaultDispatcher; |
182 | 182 | } |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | * @param $callable |
189 | 189 | * @return |
190 | 190 | */ |
191 | - protected function registerCommand($commandName, $callable){ |
|
191 | + protected function registerCommand($commandName, $callable) { |
|
192 | 192 | $this->commands[$commandName] = $callable; |
193 | 193 | } |
194 | 194 | |
@@ -198,10 +198,10 @@ discard block |
||
198 | 198 | * @param $cmdMessage |
199 | 199 | * @return |
200 | 200 | */ |
201 | - public function command(\PEIP\INF\Message\Message $cmdMessage){ |
|
201 | + public function command(\PEIP\INF\Message\Message $cmdMessage) { |
|
202 | 202 | $this->doFireEvent(self::EVENT_PRE_COMMAND, array(self::HEADER_MESSAGE=>$cmdMessage)); |
203 | 203 | $commandName = trim((string)$cmdMessage->getHeader('COMMAND')); |
204 | - if($commandName != '' && array_key_exists($commandName, $this->commands)){ |
|
204 | + if ($commandName != '' && array_key_exists($commandName, $this->commands)) { |
|
205 | 205 | call_user_func($this->commands[$commandName], $cmdMessage->getContent()); |
206 | 206 | } |
207 | 207 | $this->doFireEvent(self::EVENT_POST_COMMAND, array(self::HEADER_MESSAGE=>$cmdMessage)); |
@@ -108,7 +108,7 @@ |
||
108 | 108 | //if(\PEIP\Util\Test::assertMessage($message)){ |
109 | 109 | if($this->getOutputChannel()){ |
110 | 110 | $this->getOutputChannel()->send($message); |
111 | - }else{ |
|
111 | + } else{ |
|
112 | 112 | $this->doSend($message); |
113 | 113 | } |
114 | 114 | //} |