@@ -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( |
@@ -70,10 +70,10 @@ |
||
70 | 70 | ), |
71 | 71 | $object |
72 | 72 | ); |
73 | - }else{ |
|
73 | + } else{ |
|
74 | 74 | throw new \InvalidArgumentException('instance of \PEIP\INF\Event\Event must contain subject'); |
75 | 75 | } |
76 | - }else{ |
|
76 | + } else{ |
|
77 | 77 | throw new \InvalidArgumentException('object must be instance of \PEIP\INF\Event\Event'); |
78 | 78 | } |
79 | 79 | } //put your code here |
@@ -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 | } |
@@ -20,7 +20,7 @@ |
||
20 | 20 | * @implements \PEIP\INF\Base\Container, \PEIP\INF\Message\Message, \PEIP\INF\Base\Buildable |
21 | 21 | */ |
22 | 22 | |
23 | -use PEIP\Util\Test; |
|
23 | +use PEIP\Util\Test; |
|
24 | 24 | use PEIP\Base\GenericBuilder; |
25 | 25 | |
26 | 26 | class GenericMessage |
@@ -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 | } |
@@ -83,7 +83,6 @@ |
||
83 | 83 | * @param ObjectEventDispatcher $dispatcher the dispatcher to dispatch the event |
84 | 84 | * @param mixed $subject the subject for the event |
85 | 85 | * @param string $name the name of the event |
86 | - * @param array $parameters the headers for the event |
|
87 | 86 | * @return |
88 | 87 | */ |
89 | 88 | public function buildAndDispatch(ObjectEventDispatcher $dispatcher, $subject, $name, array $headers = array()){ |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * @param string $eventClass the event-class the builder shall create instances for |
38 | 38 | * @param array $defaultHeaders default headers for the created events |
39 | 39 | */ |
40 | - public function __construct($eventClass = '\PEIP\Event\Event', array $defaultHeaders = array()){ |
|
40 | + public function __construct($eventClass = '\PEIP\Event\Event', array $defaultHeaders = array()) { |
|
41 | 41 | $this->eventClass = $eventClass; |
42 | 42 | $this->defaultParameters = $defaultHeaders; |
43 | 43 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @param string $eventClass the event-class the builder shall create instances for |
50 | 50 | * @return EventBuilder the instance of EventBuilder for the given event-class |
51 | 51 | */ |
52 | - public static function getInstance($eventClass = '\PEIP\Event\Event'){ |
|
52 | + public static function getInstance($eventClass = '\PEIP\Event\Event') { |
|
53 | 53 | |
54 | 54 | return isset(self::$instances[$eventClass]) |
55 | 55 | ? self::$instances[$eventClass] |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @param array $headers the headers for the event |
68 | 68 | * @return object event instance |
69 | 69 | */ |
70 | - public function build($subject, $name, array $headers = array()){ |
|
70 | + public function build($subject, $name, array $headers = array()) { |
|
71 | 71 | |
72 | 72 | return new $this->eventClass( |
73 | 73 | $subject, |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @param array $parameters the headers for the event |
87 | 87 | * @return |
88 | 88 | */ |
89 | - public function buildAndDispatch(ObjectEventDispatcher $dispatcher, $subject, $name, array $headers = array()){ |
|
89 | + public function buildAndDispatch(ObjectEventDispatcher $dispatcher, $subject, $name, array $headers = array()) { |
|
90 | 90 | |
91 | 91 | return $dispatcher->notify( |
92 | 92 | $name, |
@@ -47,6 +47,9 @@ |
||
47 | 47 | return new DedicatedFactory(array($class, '__construct'), $parameters); |
48 | 48 | } |
49 | 49 | |
50 | + /** |
|
51 | + * @param string[] $callable |
|
52 | + */ |
|
50 | 53 | public static function getfromCallable($callable, array $parameters = array()){ |
51 | 54 | return new DedicatedFactory($callable, $parameters); |
52 | 55 | } |
@@ -38,16 +38,16 @@ discard block |
||
38 | 38 | * @param $parameters |
39 | 39 | * @return |
40 | 40 | */ |
41 | - protected function __construct($callable ,array $parameters = array()){ |
|
41 | + protected function __construct($callable, array $parameters = array()) { |
|
42 | 42 | $this->callable = $callable; |
43 | 43 | $this->setParameters($parameters); |
44 | 44 | } |
45 | 45 | |
46 | - public static function getfromClass($class, array $parameters = array()){ |
|
46 | + public static function getfromClass($class, array $parameters = array()) { |
|
47 | 47 | return new DedicatedFactory(array($class, '__construct'), $parameters); |
48 | 48 | } |
49 | 49 | |
50 | - public static function getfromCallable($callable, array $parameters = array()){ |
|
50 | + public static function getfromCallable($callable, array $parameters = array()) { |
|
51 | 51 | return new DedicatedFactory($callable, $parameters); |
52 | 52 | } |
53 | 53 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @param $arguments |
58 | 58 | * @return |
59 | 59 | */ |
60 | - public function build(array $arguments = array()){ |
|
60 | + public function build(array $arguments = array()) { |
|
61 | 61 | $arguments = count($arguments) > 0 ? $arguments : $this->getParameters(); |
62 | 62 | return (is_array($this->callable) && $this->callable[1] == '__construct') |
63 | 63 | ? GenericBuilder::GetInstance($this->callable[0])->build($arguments) |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @param $method |
71 | 71 | * @return |
72 | 72 | */ |
73 | - public function setConstructor($method){ |
|
73 | + public function setConstructor($method) { |
|
74 | 74 | $this->constructor = (string)$method; |
75 | 75 | return $this; |
76 | 76 | } |
@@ -71,7 +71,7 @@ |
||
71 | 71 | * @see GenericBuilder |
72 | 72 | * @static |
73 | 73 | * @access protected |
74 | - * @param object $className name of class to build instance for. |
|
74 | + * @param string $className name of class to build instance for. |
|
75 | 75 | * @param array $arguments arguments for the constructor |
76 | 76 | * @return object build and modified srvice instance |
77 | 77 | */ |
@@ -11,8 +11,8 @@ |
||
11 | 11 | * |
12 | 12 | * @author timo |
13 | 13 | */ |
14 | -use PEIP\Util\Test; |
|
15 | -use PEIP\Base\GenericBuilder; |
|
14 | +use PEIP\Util\Test; |
|
15 | +use PEIP\Base\GenericBuilder; |
|
16 | 16 | use PEIP\Context\XMLContext; |
17 | 17 | |
18 | 18 | class ServiceFactory { |
@@ -16,13 +16,13 @@ discard block |
||
16 | 16 | use PEIP\Context\XMLContext; |
17 | 17 | |
18 | 18 | class ServiceFactory { |
19 | - /** |
|
20 | - * Creates and initializes service instance from a given configuration. |
|
21 | - * |
|
22 | - * @access public |
|
23 | - * @param $config |
|
24 | - * @return object the initialized service instance |
|
25 | - */ |
|
19 | + /** |
|
20 | + * Creates and initializes service instance from a given configuration. |
|
21 | + * |
|
22 | + * @access public |
|
23 | + * @param $config |
|
24 | + * @return object the initialized service instance |
|
25 | + */ |
|
26 | 26 | public static function createService($config){ |
27 | 27 | $args = array(); |
28 | 28 | //build arguments for constructor |
@@ -35,15 +35,15 @@ discard block |
||
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
38 | - * Builds an arbitrary service/object instance from a config-obect. |
|
39 | - * |
|
40 | - * @static |
|
41 | - * @access protected |
|
42 | - * @param object $config configuration object to build a service instance from. |
|
43 | - * @param array $arguments arguments for the service constructor |
|
44 | - * @param string $defaultClass class to create instance for if none is set in config |
|
45 | - * @return object build and modified srvice instance |
|
46 | - */ |
|
38 | + * Builds an arbitrary service/object instance from a config-obect. |
|
39 | + * |
|
40 | + * @static |
|
41 | + * @access protected |
|
42 | + * @param object $config configuration object to build a service instance from. |
|
43 | + * @param array $arguments arguments for the service constructor |
|
44 | + * @param string $defaultClass class to create instance for if none is set in config |
|
45 | + * @return object build and modified srvice instance |
|
46 | + */ |
|
47 | 47 | public static function doBuild($config, $arguments, $defaultClass = false){ |
48 | 48 | $cls = $config["class"] ? trim((string)$config["class"]) : (string)$defaultClass; |
49 | 49 | if($cls != ''){ |
@@ -80,12 +80,12 @@ discard block |
||
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
83 | - * Builds single argument (to call a method with later) from a config-obect. |
|
84 | - * |
|
85 | - * @access protected |
|
86 | - * @param object $config configuration object to create argument from. |
|
87 | - * @return mixed build argument |
|
88 | - */ |
|
83 | + * Builds single argument (to call a method with later) from a config-obect. |
|
84 | + * |
|
85 | + * @access protected |
|
86 | + * @param object $config configuration object to create argument from. |
|
87 | + * @return mixed build argument |
|
88 | + */ |
|
89 | 89 | protected static function buildArg($config){ |
90 | 90 | if(trim((string)$config['value']) != ''){ |
91 | 91 | $arg = (string)$config['value']; |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | */ |
129 | 129 | public static function buildAndModify($config, $arguments, $defaultClass = false){ |
130 | 130 | if("" != (string)$config["class"] || $defaultClass){ |
131 | - $service = ServiceFactory::doBuild($config, $arguments, $defaultClass); |
|
131 | + $service = ServiceFactory::doBuild($config, $arguments, $defaultClass); |
|
132 | 132 | }else{ |
133 | 133 | throw new \RuntimeException('Could not create Service. no class or reference given.'); |
134 | 134 | } |
@@ -23,11 +23,11 @@ discard block |
||
23 | 23 | * @param $config |
24 | 24 | * @return object the initialized service instance |
25 | 25 | */ |
26 | - public static function createService($config){ |
|
26 | + public static function createService($config) { |
|
27 | 27 | $args = array(); |
28 | 28 | //build arguments for constructor |
29 | - if($config->constructor_arg){ |
|
30 | - foreach($config->constructor_arg as $arg){ |
|
29 | + if ($config->constructor_arg) { |
|
30 | + foreach ($config->constructor_arg as $arg) { |
|
31 | 31 | $args[] = self::buildArg($arg); |
32 | 32 | } |
33 | 33 | } |
@@ -44,21 +44,21 @@ discard block |
||
44 | 44 | * @param string $defaultClass class to create instance for if none is set in config |
45 | 45 | * @return object build and modified srvice instance |
46 | 46 | */ |
47 | - public static function doBuild($config, $arguments, $defaultClass = false){ |
|
47 | + public static function doBuild($config, $arguments, $defaultClass = false) { |
|
48 | 48 | $cls = $config["class"] ? trim((string)$config["class"]) : (string)$defaultClass; |
49 | - if($cls != ''){ |
|
49 | + if ($cls != '') { |
|
50 | 50 | try { |
51 | 51 | $constructor = (string)$config["constructor"]; |
52 | - if($constructor != '' && Test::assertMethod($cls, $constructor)){ |
|
52 | + if ($constructor != '' && Test::assertMethod($cls, $constructor)) { |
|
53 | 53 | $service = call_user_func_array(array($cls, $constructor), $arguments); |
54 | - }else{ |
|
54 | + }else { |
|
55 | 55 | $service = self::build($cls, $arguments); |
56 | 56 | } |
57 | - }catch(\Exception $e){ |
|
57 | + } catch (\Exception $e) { |
|
58 | 58 | throw new \RuntimeException('Could not create Service "'.$cls.'" -> '.$e->getMessage()); |
59 | 59 | } |
60 | 60 | } |
61 | - if(is_object($service)){ |
|
61 | + if (is_object($service)) { |
|
62 | 62 | return $service; |
63 | 63 | } |
64 | 64 | throw new \RuntimeException('Could not create Service "'.$cls.'". Class does not exist.'); |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * @param array $arguments arguments for the constructor |
76 | 76 | * @return object build and modified srvice instance |
77 | 77 | */ |
78 | - public static function build($className, $arguments){ |
|
78 | + public static function build($className, $arguments) { |
|
79 | 79 | return GenericBuilder::getInstance($className)->build($arguments); |
80 | 80 | } |
81 | 81 | |
@@ -86,29 +86,29 @@ discard block |
||
86 | 86 | * @param object $config configuration object to create argument from. |
87 | 87 | * @return mixed build argument |
88 | 88 | */ |
89 | - protected static function buildArg($config){ |
|
90 | - if(trim((string)$config['value']) != ''){ |
|
89 | + protected static function buildArg($config) { |
|
90 | + if (trim((string)$config['value']) != '') { |
|
91 | 91 | $arg = (string)$config['value']; |
92 | - }elseif($config->getName() == 'value'){ |
|
92 | + }elseif ($config->getName() == 'value') { |
|
93 | 93 | $arg = (string)$config; |
94 | - }elseif($config->getName() == 'list'){ |
|
94 | + }elseif ($config->getName() == 'list') { |
|
95 | 95 | $arg = array(); |
96 | - foreach($config->children() as $entry){ |
|
97 | - if($entry->getName() == 'value'){ |
|
98 | - if($entry['key']){ |
|
96 | + foreach ($config->children() as $entry) { |
|
97 | + if ($entry->getName() == 'value') { |
|
98 | + if ($entry['key']) { |
|
99 | 99 | $arg[(string)$entry['key']] = (string)$entry; |
100 | - }else{ |
|
100 | + }else { |
|
101 | 101 | $arg[] = (string)$entry; |
102 | 102 | } |
103 | - }elseif($entry->getName() == 'service'){ |
|
103 | + }elseif ($entry->getName() == 'service') { |
|
104 | 104 | $arg[] = $this->provideService($entry); |
105 | 105 | } |
106 | 106 | } |
107 | - }elseif($config->getName() == 'service'){ |
|
107 | + }elseif ($config->getName() == 'service') { |
|
108 | 108 | $arg = self::provideService($config); |
109 | - }elseif($config->list){ |
|
109 | + }elseif ($config->list) { |
|
110 | 110 | $arg = self::buildArg($config->list); |
111 | - }elseif($config->service){ |
|
111 | + }elseif ($config->service) { |
|
112 | 112 | $arg = self::buildArg($config->service); |
113 | 113 | } |
114 | 114 | return $arg; |
@@ -126,24 +126,24 @@ discard block |
||
126 | 126 | * @param string $defaultClass class to create instance for if none is set in config |
127 | 127 | * @return object build and modified srvice instance |
128 | 128 | */ |
129 | - public static function buildAndModify($config, $arguments, $defaultClass = false){ |
|
130 | - if("" != (string)$config["class"] || $defaultClass){ |
|
129 | + public static function buildAndModify($config, $arguments, $defaultClass = false) { |
|
130 | + if ("" != (string)$config["class"] || $defaultClass) { |
|
131 | 131 | $service = ServiceFactory::doBuild($config, $arguments, $defaultClass); |
132 | - }else{ |
|
132 | + }else { |
|
133 | 133 | throw new \RuntimeException('Could not create Service. no class or reference given.'); |
134 | 134 | } |
135 | - if($config["ref_property"]){ |
|
135 | + if ($config["ref_property"]) { |
|
136 | 136 | $service = $service->{(string)$config["ref_property"]}; |
137 | - }elseif($config["ref_method"]){ |
|
137 | + }elseif ($config["ref_method"]) { |
|
138 | 138 | $args = array(); |
139 | - if($config->argument){ |
|
140 | - foreach($config->argument as $arg){ |
|
139 | + if ($config->argument) { |
|
140 | + foreach ($config->argument as $arg) { |
|
141 | 141 | $args[] = $this->buildArg($arg); |
142 | 142 | } |
143 | 143 | } |
144 | 144 | $service = call_user_func_array(array($service, (string)$config["ref_method"]), $args); |
145 | 145 | } |
146 | - if(!is_object($service)){ |
|
146 | + if (!is_object($service)) { |
|
147 | 147 | throw new \RuntimeException('Could not create Service.'); |
148 | 148 | } |
149 | 149 | $service = self::modifyService($service, $config); |
@@ -166,29 +166,29 @@ discard block |
||
166 | 166 | * @param object $config configuration to get the modification instructions from. |
167 | 167 | * @return object the modificated service |
168 | 168 | */ |
169 | - protected function modifyService($service, $config){ |
|
169 | + protected function modifyService($service, $config) { |
|
170 | 170 | $reflection = GenericBuilder::getInstance(get_class($service))->getReflectionClass(); |
171 | 171 | // set instance properties |
172 | - if($config->property){ |
|
173 | - foreach($config->property as $property){ |
|
172 | + if ($config->property) { |
|
173 | + foreach ($config->property as $property) { |
|
174 | 174 | $arg = self::buildArg($property); |
175 | - if($arg){ |
|
175 | + if ($arg) { |
|
176 | 176 | $setter = self::getSetter($property); |
177 | - if($setter && self::hasPublicProperty($service, 'Method', $setter)){ |
|
177 | + if ($setter && self::hasPublicProperty($service, 'Method', $setter)) { |
|
178 | 178 | $service->{$setter}($arg); |
179 | - }elseif(in_array($property, self::hasPublicProperty($service, 'Property', $setter))){ |
|
179 | + }elseif (in_array($property, self::hasPublicProperty($service, 'Property', $setter))) { |
|
180 | 180 | $service->$setter = $arg; |
181 | 181 | } |
182 | 182 | } |
183 | 183 | } |
184 | 184 | } |
185 | 185 | // call instance methods |
186 | - if($config->action){ |
|
187 | - foreach($config->action as $action){ |
|
186 | + if ($config->action) { |
|
187 | + foreach ($config->action as $action) { |
|
188 | 188 | $method = (string)$action['method'] != '' ? (string)$action['method'] : NULL; |
189 | - if($method && self::hasPublicProperty($service, 'Method', $method)){ |
|
189 | + if ($method && self::hasPublicProperty($service, 'Method', $method)) { |
|
190 | 190 | $args = array(); |
191 | - foreach($action->children() as $argument){ |
|
191 | + foreach ($action->children() as $argument) { |
|
192 | 192 | $args[] = $this->buildArg($argument); |
193 | 193 | } |
194 | 194 | call_user_func_array(array($service, (string)$action['method']), $args); |
@@ -196,9 +196,9 @@ discard block |
||
196 | 196 | } |
197 | 197 | } |
198 | 198 | // register instance listeners |
199 | - if($service instanceof \PEIP\INF\Event\Connectable){ |
|
200 | - if($config->listener){ |
|
201 | - foreach($config->listener as $listenerConf){ |
|
199 | + if ($service instanceof \PEIP\INF\Event\Connectable) { |
|
200 | + if ($config->listener) { |
|
201 | + foreach ($config->listener as $listenerConf) { |
|
202 | 202 | $event = (string)$listenerConf['event']; |
203 | 203 | $listener = $this->provideService($listenerConf); |
204 | 204 | $service->connect($event, $listener); |
@@ -51,10 +51,10 @@ discard block |
||
51 | 51 | $constructor = (string)$config["constructor"]; |
52 | 52 | if($constructor != '' && Test::assertMethod($cls, $constructor)){ |
53 | 53 | $service = call_user_func_array(array($cls, $constructor), $arguments); |
54 | - }else{ |
|
54 | + } else{ |
|
55 | 55 | $service = self::build($cls, $arguments); |
56 | 56 | } |
57 | - }catch(\Exception $e){ |
|
57 | + } catch(\Exception $e){ |
|
58 | 58 | throw new \RuntimeException('Could not create Service "'.$cls.'" -> '.$e->getMessage()); |
59 | 59 | } |
60 | 60 | } |
@@ -89,26 +89,26 @@ discard block |
||
89 | 89 | protected static function buildArg($config){ |
90 | 90 | if(trim((string)$config['value']) != ''){ |
91 | 91 | $arg = (string)$config['value']; |
92 | - }elseif($config->getName() == 'value'){ |
|
92 | + } elseif($config->getName() == 'value'){ |
|
93 | 93 | $arg = (string)$config; |
94 | - }elseif($config->getName() == 'list'){ |
|
94 | + } elseif($config->getName() == 'list'){ |
|
95 | 95 | $arg = array(); |
96 | 96 | foreach($config->children() as $entry){ |
97 | 97 | if($entry->getName() == 'value'){ |
98 | 98 | if($entry['key']){ |
99 | 99 | $arg[(string)$entry['key']] = (string)$entry; |
100 | - }else{ |
|
100 | + } else{ |
|
101 | 101 | $arg[] = (string)$entry; |
102 | 102 | } |
103 | - }elseif($entry->getName() == 'service'){ |
|
103 | + } elseif($entry->getName() == 'service'){ |
|
104 | 104 | $arg[] = $this->provideService($entry); |
105 | 105 | } |
106 | 106 | } |
107 | - }elseif($config->getName() == 'service'){ |
|
107 | + } elseif($config->getName() == 'service'){ |
|
108 | 108 | $arg = self::provideService($config); |
109 | - }elseif($config->list){ |
|
109 | + } elseif($config->list){ |
|
110 | 110 | $arg = self::buildArg($config->list); |
111 | - }elseif($config->service){ |
|
111 | + } elseif($config->service){ |
|
112 | 112 | $arg = self::buildArg($config->service); |
113 | 113 | } |
114 | 114 | return $arg; |
@@ -129,12 +129,12 @@ discard block |
||
129 | 129 | public static function buildAndModify($config, $arguments, $defaultClass = false){ |
130 | 130 | if("" != (string)$config["class"] || $defaultClass){ |
131 | 131 | $service = ServiceFactory::doBuild($config, $arguments, $defaultClass); |
132 | - }else{ |
|
132 | + } else{ |
|
133 | 133 | throw new \RuntimeException('Could not create Service. no class or reference given.'); |
134 | 134 | } |
135 | 135 | if($config["ref_property"]){ |
136 | 136 | $service = $service->{(string)$config["ref_property"]}; |
137 | - }elseif($config["ref_method"]){ |
|
137 | + } elseif($config["ref_method"]){ |
|
138 | 138 | $args = array(); |
139 | 139 | if($config->argument){ |
140 | 140 | foreach($config->argument as $arg){ |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | $setter = self::getSetter($property); |
177 | 177 | if($setter && self::hasPublicProperty($service, 'Method', $setter)){ |
178 | 178 | $service->{$setter}($arg); |
179 | - }elseif(in_array($property, self::hasPublicProperty($service, 'Property', $setter))){ |
|
179 | + } elseif(in_array($property, self::hasPublicProperty($service, 'Property', $setter))){ |
|
180 | 180 | $service->$setter = $arg; |
181 | 181 | } |
182 | 182 | } |
@@ -56,7 +56,6 @@ |
||
56 | 56 | * sets the channel to send requests from the gateway |
57 | 57 | * |
58 | 58 | * @access public |
59 | - * @param \PEIP\INF\Channel\Channel $replyChannel The default channel to receive requests from the gateway |
|
60 | 59 | * @return |
61 | 60 | */ |
62 | 61 | public function setRequestChannel(\PEIP\INF\Channel\Channel $requestChannel){ |
@@ -20,7 +20,7 @@ |
||
20 | 20 | * @implements \PEIP\INF\Gateway\MessagingGateway, \PEIP\INF\Message\MessageBuilder |
21 | 21 | */ |
22 | 22 | |
23 | -use PEIP\Message\GenericMessage; |
|
23 | +use PEIP\Message\GenericMessage; |
|
24 | 24 | use PEIP\Message\MessageBuilder; |
25 | 25 | |
26 | 26 | class SimpleMessagingGateway |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | * @param \PEIP\INF\Channel\PollableChannel $replyChannel The default channel to receive requests from the gateway |
44 | 44 | * @param array $defaultHeaders The default headers to apply to request messages |
45 | 45 | */ |
46 | - public function __construct(\PEIP\INF\Channel\Channel $requestChannel, \PEIP\INF\Channel\Channel $replyChannel = NULL, array $defaultHeaders = array()){ |
|
46 | + public function __construct(\PEIP\INF\Channel\Channel $requestChannel, \PEIP\INF\Channel\Channel $replyChannel = NULL, array $defaultHeaders = array()) { |
|
47 | 47 | $this->setRequestChannel($requestChannel); |
48 | - if($replyChannel){ |
|
48 | + if ($replyChannel) { |
|
49 | 49 | $this->setReplyChannel($replyChannel); |
50 | 50 | } |
51 | 51 | $this->defaultHeaders = $defaultHeaders; |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @param \PEIP\INF\Channel\Channel $replyChannel The default channel to receive requests from the gateway |
60 | 60 | * @return |
61 | 61 | */ |
62 | - public function setRequestChannel(\PEIP\INF\Channel\Channel $requestChannel){ |
|
62 | + public function setRequestChannel(\PEIP\INF\Channel\Channel $requestChannel) { |
|
63 | 63 | $this->requestChannel = $requestChannel; |
64 | 64 | } |
65 | 65 | |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | * @param \PEIP\INF\Channel\PollableChannel $replyChannel The default channel to receive requests from the gateway |
71 | 71 | * @return |
72 | 72 | */ |
73 | - public function setReplyChannel(\PEIP\INF\Channel\Channel $replyChannel){ |
|
74 | - if(!($replyChannel instanceof \PEIP\INF\Channel\PollableChannel)){ |
|
73 | + public function setReplyChannel(\PEIP\INF\Channel\Channel $replyChannel) { |
|
74 | + if (!($replyChannel instanceof \PEIP\INF\Channel\PollableChannel)) { |
|
75 | 75 | throw new \InvalidArgumentException('reply channel must be instance of \PEIP\INF\Channel\PollableChannel.'); |
76 | 76 | } |
77 | 77 | $this->replyChannel = $replyChannel; |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @param mixed $content the content/payload for the message to send |
85 | 85 | * @return |
86 | 86 | */ |
87 | - public function send($content){ |
|
87 | + public function send($content) { |
|
88 | 88 | return $this->requestChannel->send($this->buildMessage($content)); |
89 | 89 | } |
90 | 90 | |
@@ -94,12 +94,12 @@ discard block |
||
94 | 94 | * @access public |
95 | 95 | * @return mixed content/payload of the received message |
96 | 96 | */ |
97 | - public function receive(){ |
|
98 | - if(!isset($this->replyChannel)){ |
|
97 | + public function receive() { |
|
98 | + if (!isset($this->replyChannel)) { |
|
99 | 99 | throw new \LogicException('No replyChannel set.'); |
100 | 100 | } |
101 | 101 | $message = $this->replyChannel->receive(); |
102 | - if($message){ |
|
102 | + if ($message) { |
|
103 | 103 | return $message->getContent(); |
104 | 104 | } |
105 | 105 | return NULL; |
@@ -112,12 +112,12 @@ discard block |
||
112 | 112 | * @param mixed $content the content/payload for the message to send |
113 | 113 | * @return mixed content/payload of the received message |
114 | 114 | */ |
115 | - public function sendAndReceive($content){ |
|
115 | + public function sendAndReceive($content) { |
|
116 | 116 | $this->send($content); |
117 | 117 | try { |
118 | 118 | $res = $this->receive(); |
119 | 119 | } |
120 | - catch(\Exception $e){ |
|
120 | + catch (\Exception $e) { |
|
121 | 121 | return NULL; |
122 | 122 | } |
123 | 123 | return $res; |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * @param mixed $content the content/payload for the message to send |
131 | 131 | * @return \PEIP\INF\Message\Message the built message |
132 | 132 | */ |
133 | - protected function buildMessage($content){ |
|
133 | + protected function buildMessage($content) { |
|
134 | 134 | return $this->getMessageBuilder()->setContent($content)->build(); |
135 | 135 | } |
136 | 136 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @access protected |
141 | 141 | * @return MessageBuilder message builder instance for the registerd message class |
142 | 142 | */ |
143 | - protected function getMessageBuilder(){ |
|
143 | + protected function getMessageBuilder() { |
|
144 | 144 | return isset($this->messageBuilder) && ($this->messageBuilder->getMessageClass() == $this->getMessageClass()) |
145 | 145 | ? $this->messageBuilder |
146 | 146 | : $this->messageBuilder = MessageBuilder::getInstance($this->messageClass)->setHeaders($this->defaultHeaders); |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @param string $messageClass message class to create instances from |
154 | 154 | * @return |
155 | 155 | */ |
156 | - public function setMessageClass($messageClass){ |
|
156 | + public function setMessageClass($messageClass) { |
|
157 | 157 | $this->messageClass = $messageClass; |
158 | 158 | } |
159 | 159 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * @access public |
164 | 164 | * @return string message class to create instances from |
165 | 165 | */ |
166 | - public function getMessageClass(){ |
|
166 | + public function getMessageClass() { |
|
167 | 167 | return $this->messageClass; |
168 | 168 | } |
169 | 169 |
@@ -116,8 +116,7 @@ |
||
116 | 116 | $this->send($content); |
117 | 117 | try { |
118 | 118 | $res = $this->receive(); |
119 | - } |
|
120 | - catch(\Exception $e){ |
|
119 | + } catch(\Exception $e){ |
|
121 | 120 | return NULL; |
122 | 121 | } |
123 | 122 | 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 void 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 | */ |
@@ -20,7 +20,7 @@ |
||
20 | 20 | * @implements \PEIP\INF\Base\Container, \PEIP\INF\Message\Message, \PEIP\INF\Base\Buildable |
21 | 21 | */ |
22 | 22 | |
23 | -use PEIP\Util\Test; |
|
23 | +use PEIP\Util\Test; |
|
24 | 24 | use PEIP\Base\GenericBuilder; |
25 | 25 | |
26 | 26 | class GenericMessage |
@@ -76,11 +76,11 @@ |
||
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
79 | - * returns all headers of the message |
|
80 | - * |
|
81 | - * @access public |
|
82 | - * @return ArrayAccess ArrayAccess object of headers |
|
83 | - */ |
|
79 | + * returns all headers of the message |
|
80 | + * |
|
81 | + * @access public |
|
82 | + * @return ArrayAccess ArrayAccess object of headers |
|
83 | + */ |
|
84 | 84 | public function getHeaders(){ |
85 | 85 | return (array) $this->headers; |
86 | 86 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @param mixed $content The content/payload of the message |
42 | 42 | * @param array|ArrayAccess $headers headers as key/value pairs |
43 | 43 | */ |
44 | - public function __construct($content, $headers = array()){ |
|
44 | + public function __construct($content, $headers = array()) { |
|
45 | 45 | $this->doSetContent($content); |
46 | 46 | $this->doSetHeaders($headers); |
47 | 47 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * @access public |
54 | 54 | * @return |
55 | 55 | */ |
56 | - public function getContent(){ |
|
56 | + public function getContent() { |
|
57 | 57 | return $this->content; |
58 | 58 | } |
59 | 59 | |
@@ -63,13 +63,13 @@ discard block |
||
63 | 63 | * @access protected |
64 | 64 | * @param mixed $content The content/payload of the message |
65 | 65 | */ |
66 | - protected function doSetContent($content){ |
|
66 | + protected function doSetContent($content) { |
|
67 | 67 | $this->content = Test::castType($content, self::CONTENT_CAST_TYPE); |
68 | 68 | } |
69 | 69 | |
70 | - protected function doSetHeaders($headers){ |
|
70 | + protected function doSetHeaders($headers) { |
|
71 | 71 | $headers = Test::ensureArrayAccess($headers); |
72 | - if(is_array($headers)){ |
|
72 | + if (is_array($headers)) { |
|
73 | 73 | $headers = new \ArrayObject($headers); |
74 | 74 | } |
75 | 75 | $this->headers = $headers; |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | * @access public |
82 | 82 | * @return ArrayAccess ArrayAccess object of headers |
83 | 83 | */ |
84 | - public function getHeaders(){ |
|
85 | - return (array) $this->headers; |
|
84 | + public function getHeaders() { |
|
85 | + return (array)$this->headers; |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * @param string $name the name of the header |
93 | 93 | * @return mixed the value of the header |
94 | 94 | */ |
95 | - public function getHeader($name){ |
|
95 | + public function getHeader($name) { |
|
96 | 96 | $name = (string)$name; |
97 | 97 | return isset($this->headers[$name]) ? $this->headers[$name] : NULL; |
98 | 98 | } |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | * @param string $name the name of the header |
106 | 106 | * @return boolean wether the header has been successfully set |
107 | 107 | */ |
108 | - public function addHeader($name, $value){ |
|
109 | - if(!$this->hasHeader($name)){ |
|
108 | + public function addHeader($name, $value) { |
|
109 | + if (!$this->hasHeader($name)) { |
|
110 | 110 | $this->headers[$name] = $value; |
111 | 111 | return true; |
112 | 112 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | * @param string $name the name of the header |
121 | 121 | * @return boolean wether the header is set |
122 | 122 | */ |
123 | - public function hasHeader($name){ |
|
123 | + public function hasHeader($name) { |
|
124 | 124 | return isset($this->headers[$name]); |
125 | 125 | } |
126 | 126 | |
@@ -130,16 +130,16 @@ discard block |
||
130 | 130 | * @access public |
131 | 131 | * @return string content/payload of the message |
132 | 132 | */ |
133 | - public function __toString(){ |
|
133 | + public function __toString() { |
|
134 | 134 | $res = false; |
135 | 135 | try { |
136 | 136 | $res = (string)$this->getContent(); |
137 | 137 | } |
138 | - catch(\Exception $e){ |
|
138 | + catch (\Exception $e) { |
|
139 | 139 | try { |
140 | 140 | $res = get_class($this->getContent()); |
141 | 141 | } |
142 | - catch(\Exception $e){ |
|
142 | + catch (\Exception $e) { |
|
143 | 143 | |
144 | 144 | } |
145 | 145 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | * @param array $arguments argumends for the constructor |
160 | 160 | * @return GenericMessage new class instance |
161 | 161 | */ |
162 | - public static function build(array $arguments = array()){ |
|
162 | + public static function build(array $arguments = array()) { |
|
163 | 163 | return GenericBuilder::getInstance(__CLASS__)->build($arguments); |
164 | 164 | } |
165 | 165 | } |
166 | 166 | \ No newline at end of file |
@@ -134,12 +134,10 @@ |
||
134 | 134 | $res = false; |
135 | 135 | try { |
136 | 136 | $res = (string)$this->getContent(); |
137 | - } |
|
138 | - catch(\Exception $e){ |
|
137 | + } catch(\Exception $e){ |
|
139 | 138 | try { |
140 | 139 | $res = get_class($this->getContent()); |
141 | - } |
|
142 | - catch(\Exception $e){ |
|
140 | + } catch(\Exception $e){ |
|
143 | 141 | |
144 | 142 | } |
145 | 143 | } |