@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @param $type |
48 | 48 | * @return |
49 | 49 | */ |
50 | - public function __construct($type){ |
|
50 | + public function __construct($type) { |
|
51 | 51 | $this->type = $type; |
52 | 52 | } |
53 | 53 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @param $message |
58 | 58 | * @return |
59 | 59 | */ |
60 | - public function acceptMessage(\PEIP\INF\Message\Message $message){ |
|
60 | + public function acceptMessage(\PEIP\INF\Message\Message $message) { |
|
61 | 61 | return call_user_func(self::$types[$this->type], $message->getContent()); |
62 | 62 | } |
63 | 63 |
@@ -39,7 +39,7 @@ |
||
39 | 39 | * |
40 | 40 | * @access public |
41 | 41 | * @param string $className class-name to create objects for |
42 | - * @param ReflectionClass $reflectionClass reflection-class for class. default: NULL |
|
42 | + * @param \ReflectionClass $reflectionClass reflection-class for class. default: NULL |
|
43 | 43 | * @param boolean $storeRef wether to store a reference for new instance. default: true |
44 | 44 | * @return |
45 | 45 | */ |
@@ -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 |
@@ -43,10 +43,10 @@ discard block |
||
43 | 43 | * @param boolean $storeRef wether to store a reference for new instance. default: true |
44 | 44 | * @return |
45 | 45 | */ |
46 | - public function __construct($className, \ReflectionClass $reflectionClass = NULL, $storeRef = true){ |
|
47 | - if($reflectionClass ){ |
|
46 | + public function __construct($className, \ReflectionClass $reflectionClass = NULL, $storeRef = true) { |
|
47 | + if ($reflectionClass) { |
|
48 | 48 | |
49 | - if($reflectionClass->getName() != $className){ |
|
49 | + if ($reflectionClass->getName() != $className) { |
|
50 | 50 | throw new \Exception( |
51 | 51 | 'Constructing GenericBuilder with wrong ReflectionClass' |
52 | 52 | ); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $this->reflectionClass = $reflectionClass; |
57 | 57 | } |
58 | 58 | $this->className = $className; |
59 | - if($storeRef){ |
|
59 | + if ($storeRef) { |
|
60 | 60 | self::$instances[$this->className] = $this; |
61 | 61 | } |
62 | 62 | } |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | * @param string $className class-name to return builder instance for |
69 | 69 | * @return GenericBuilder builder instance for class |
70 | 70 | */ |
71 | - public static function getInstance($className){ |
|
72 | - if(!array_key_exists((string)$className, self::$instances)) { |
|
71 | + public static function getInstance($className) { |
|
72 | + if (!array_key_exists((string)$className, self::$instances)) { |
|
73 | 73 | new GenericBuilder($className); |
74 | 74 | } |
75 | 75 | return self::$instances[$className]; |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | * @param array $arguments array of constructore arguments |
83 | 83 | * @return object the created object instance |
84 | 84 | */ |
85 | - public function build(array $arguments = array()){ |
|
86 | - if(Test::assertClassHasConstructor($this->className)){ |
|
87 | - if(!Test::assertRequiredConstructorParameters($this->className, $arguments)){ |
|
85 | + public function build(array $arguments = array()) { |
|
86 | + if (Test::assertClassHasConstructor($this->className)) { |
|
87 | + if (!Test::assertRequiredConstructorParameters($this->className, $arguments)) { |
|
88 | 88 | throw new \Exception('Missing Argument '.(count($arguments) + 1).' for '.$this->className.'::__construct'); |
89 | 89 | } |
90 | 90 | return $this->getReflectionClass()->newInstanceArgs($arguments); |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * @access public |
99 | 99 | * @return ReflectionClass |
100 | 100 | */ |
101 | - public function getReflectionClass(){ |
|
101 | + public function getReflectionClass() { |
|
102 | 102 | return ReflectionPool::getInstance($this->className); |
103 | 103 | } |
104 | 104 |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * |
142 | 142 | * @implements \PEIP\INF\Context\Context |
143 | 143 | * @access public |
144 | - * @param \PEIP\INF\Context\Context_Plugin $plugin a plugin instance |
|
144 | + * @param \PEIP\INF\Context\ContextPlugin $plugin a plugin instance |
|
145 | 145 | */ |
146 | 146 | public function addPlugin(\PEIP\INF\Context\ContextPlugin $plugin){ |
147 | 147 | $plugin->init($this); |
@@ -173,7 +173,6 @@ discard block |
||
173 | 173 | * </config> |
174 | 174 | * |
175 | 175 | * @access public |
176 | - * @param XMLContext $config the config to include |
|
177 | 176 | */ |
178 | 177 | public function includeContext(XMLContext $context){ |
179 | 178 | $this->services = array_merge($this->services, $context->getServices()); |
@@ -184,7 +183,7 @@ discard block |
||
184 | 183 | * |
185 | 184 | * @see XMLContext::includeContext |
186 | 185 | * @access public |
187 | - * @param XMLContext $context the config to include |
|
186 | + * @param string $filePath |
|
188 | 187 | */ |
189 | 188 | public function includeContextFromFile($filePath){ |
190 | 189 | if(file_exists($filePath)){ |
@@ -363,7 +362,7 @@ discard block |
||
363 | 362 | * |
364 | 363 | * @access public |
365 | 364 | * @param $config |
366 | - * @return object the initialized service instance |
|
365 | + * @return \PEIP\INF\Context\ContextPlugin the initialized service instance |
|
367 | 366 | */ |
368 | 367 | public function createService($config){ |
369 | 368 | return ServiceFactory::createService($config); |
@@ -692,7 +691,7 @@ discard block |
||
692 | 691 | * |
693 | 692 | * @access protected |
694 | 693 | * @param object $config configuration object to create arguments from. |
695 | - * @return mixed build arguments |
|
694 | + * @return \PEIP\INF\Channel\Channel[] build arguments |
|
696 | 695 | */ |
697 | 696 | protected function getReplyHandlerArguments($config){ |
698 | 697 | $args = array( |
@@ -737,7 +736,8 @@ discard block |
||
737 | 736 | * |
738 | 737 | * @access protected |
739 | 738 | * @param string the configuration type ofthe channel (e.g.: 'reply', 'request') |
740 | - * @param object $config configuration object to return channel from. |
|
739 | + * @param object $config configuration object to return channel from. |
|
740 | + * @param string $type |
|
741 | 741 | * @return \PEIP\INF\Channel\Channel reply-channel |
742 | 742 | */ |
743 | 743 | public function doGetChannel($type, $config){ |
@@ -832,7 +832,7 @@ discard block |
||
832 | 832 | * @see GenericBuilder |
833 | 833 | * @static |
834 | 834 | * @access protected |
835 | - * @param object $className name of class to build instance for. |
|
835 | + * @param string $className name of class to build instance for. |
|
836 | 836 | * @param array $arguments arguments for the constructor |
837 | 837 | * @return object build and modified srvice instance |
838 | 838 | */ |
@@ -840,6 +840,10 @@ discard block |
||
840 | 840 | return GenericBuilder::getInstance($className)->build($arguments); |
841 | 841 | } |
842 | 842 | |
843 | + /** |
|
844 | + * @param string $type |
|
845 | + * @param string $name |
|
846 | + */ |
|
843 | 847 | protected static function hasPublicProperty($service, $type, $name){ |
844 | 848 | $reflection = GenericBuilder::getInstance(get_class($service))->getReflectionClass(); |
845 | 849 | if($reflection->{'has'.$type}($name) && $reflection->{'get'.$type}($name)->isPublic()){ |
@@ -133,7 +133,7 @@ |
||
133 | 133 | * @param callable $callable a callable which creates instances for node-name |
134 | 134 | */ |
135 | 135 | public function registerNodeBuilder($nodeName, $callable){ |
136 | - return $this->getServiceProvider()->registerNodeBuilder($nodeName, $callable); |
|
136 | + return $this->getServiceProvider()->registerNodeBuilder($nodeName, $callable); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -22,12 +22,12 @@ |
||
22 | 22 | */ |
23 | 23 | |
24 | 24 | |
25 | -use PEIP\Service\HeaderServiceActivator; |
|
26 | -use PEIP\Channel\ChannelRegistry; |
|
27 | -use PEIP\Service\ServiceProvider; |
|
28 | -use PEIP\Plugins\BasePlugin; |
|
29 | -use PEIP\Factory\ServiceFactory; |
|
30 | -use PEIP\Base\GenericBuilder; |
|
25 | +use PEIP\Service\HeaderServiceActivator; |
|
26 | +use PEIP\Channel\ChannelRegistry; |
|
27 | +use PEIP\Service\ServiceProvider; |
|
28 | +use PEIP\Plugins\BasePlugin; |
|
29 | +use PEIP\Factory\ServiceFactory; |
|
30 | +use PEIP\Base\GenericBuilder; |
|
31 | 31 | use PEIP\Context\XMLContextReader; |
32 | 32 | |
33 | 33 | class XMLContext |
@@ -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); return; |
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,29 +376,29 @@ 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 | $reflection = GenericBuilder::getInstance(get_class($service))->getReflectionClass(); |
381 | 381 | // set instance properties |
382 | - if($config->property){ |
|
383 | - foreach($config->property as $property){ |
|
382 | + if ($config->property) { |
|
383 | + foreach ($config->property as $property) { |
|
384 | 384 | $arg = $this->buildArg($property); |
385 | - if($arg){ |
|
385 | + if ($arg) { |
|
386 | 386 | $setter = self::getSetter($property); |
387 | - if($setter && self::hasPublicProperty($service, 'Method', $setter)){ |
|
387 | + if ($setter && self::hasPublicProperty($service, 'Method', $setter)) { |
|
388 | 388 | $service->{$setter}($arg); |
389 | - }elseif(in_array($property, self::hasPublicProperty($service, 'Property', $setter))){ |
|
389 | + }elseif (in_array($property, self::hasPublicProperty($service, 'Property', $setter))) { |
|
390 | 390 | $service->$setter = $arg; |
391 | 391 | } |
392 | 392 | } |
393 | 393 | } |
394 | 394 | } |
395 | 395 | // call instance methods |
396 | - if($config->action){ |
|
397 | - foreach($config->action as $action){ |
|
396 | + if ($config->action) { |
|
397 | + foreach ($config->action as $action) { |
|
398 | 398 | $method = (string)$action['method'] != '' ? (string)$action['method'] : NULL; |
399 | - if($method && self::hasPublicProperty($service, 'Method', $method)){ |
|
399 | + if ($method && self::hasPublicProperty($service, 'Method', $method)) { |
|
400 | 400 | $args = array(); |
401 | - foreach($action->children() as $argument){ |
|
401 | + foreach ($action->children() as $argument) { |
|
402 | 402 | $args[] = $this->buildArg($argument); |
403 | 403 | } |
404 | 404 | call_user_func_array(array($service, (string)$action['method']), $args); |
@@ -406,9 +406,9 @@ discard block |
||
406 | 406 | } |
407 | 407 | } |
408 | 408 | // register instance listeners |
409 | - if($service instanceof \PEIP\INF\Event\Connectable){ |
|
410 | - if($config->listener){ |
|
411 | - foreach($config->listener as $listenerConf){ |
|
409 | + if ($service instanceof \PEIP\INF\Event\Connectable) { |
|
410 | + if ($config->listener) { |
|
411 | + foreach ($config->listener as $listenerConf) { |
|
412 | 412 | $event = (string)$listenerConf['event']; |
413 | 413 | $listener = $this->provideService($listenerConf); |
414 | 414 | $service->connect($event, $listener); |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | * @param mixed $id the id ofthe gateway |
428 | 428 | * @return object the gateway instance |
429 | 429 | */ |
430 | - public function getGateway($id){ |
|
430 | + public function getGateway($id) { |
|
431 | 431 | return $this->getServiceProvider()->provideService($id); |
432 | 432 | } |
433 | 433 | |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | * @param object $config configuration object for the pollable channel. |
440 | 440 | * @return \PEIP\INF\Channel\Channel the created pollable channel instance |
441 | 441 | */ |
442 | - public function createChannel($config){ |
|
442 | + public function createChannel($config) { |
|
443 | 443 | return $this->doCreateChannel($config, 'PollableChannel'); |
444 | 444 | } |
445 | 445 | |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | * @param object $config configuration object for the subscribable channel. |
452 | 452 | * @return \PEIP\INF\Channel\Channel the created subscribable channel instance |
453 | 453 | */ |
454 | - public function createSubscribableChannel($config){ |
|
454 | + public function createSubscribableChannel($config) { |
|
455 | 455 | return $this->doCreateChannel($config, 'PublishSubscribeChannel'); |
456 | 456 | } |
457 | 457 | |
@@ -464,9 +464,9 @@ discard block |
||
464 | 464 | * @param $additionalArguments additional arguments for the channel constructor (without first arg = id) |
465 | 465 | * @return \PEIP\INF\Channel\Channel the created channel instance |
466 | 466 | */ |
467 | - public function doCreateChannel($config, $defaultChannelClass, array $additionalArguments = array()){ |
|
467 | + public function doCreateChannel($config, $defaultChannelClass, array $additionalArguments = array()) { |
|
468 | 468 | $id = (string)$config['id']; |
469 | - if($id != ''){ |
|
469 | + if ($id != '') { |
|
470 | 470 | array_unshift($additionalArguments, $id); |
471 | 471 | $channel = $this->buildAndModify($config, $additionalArguments, $defaultChannelClass); |
472 | 472 | $this->channelRegistry->register($channel); |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | * @param string $defaultClass the class to use if none is set in config. |
484 | 484 | * @return object the gateway instance |
485 | 485 | */ |
486 | - public function createGateway($config, $defaultClass = false){ |
|
486 | + public function createGateway($config, $defaultClass = false) { |
|
487 | 487 | $args = array( |
488 | 488 | $this->getRequestChannel($config), |
489 | 489 | $this->getReplyChannel($config) |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | * @param string $defaultClass the class to use if none is set in config. |
508 | 508 | * @return object the router instance |
509 | 509 | */ |
510 | - public function createRouter($config, $defaultClass = false){ |
|
510 | + public function createRouter($config, $defaultClass = false) { |
|
511 | 511 | $resolver = $config['channel_resolver'] ? (string)$config['channel_resolver'] : $this->channelRegistry; |
512 | 512 | return $this->buildAndModify($config, array( |
513 | 513 | $resolver, |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | * @param object $config configuration object for the splitter. |
525 | 525 | * @return object the splitter instance |
526 | 526 | */ |
527 | - public function createSplitter($config){ |
|
527 | + public function createSplitter($config) { |
|
528 | 528 | return $this->createReplyMessageHandler($config); |
529 | 529 | } |
530 | 530 | |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | * @param object $config configuration object for the transformer. |
538 | 538 | * @return object the transformer instance |
539 | 539 | */ |
540 | - public function createTransformer($config){ |
|
540 | + public function createTransformer($config) { |
|
541 | 541 | return $this->createReplyMessageHandler($config); |
542 | 542 | } |
543 | 543 | |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | * @param object $config configuration object for the aggregator. |
551 | 551 | * @return object the aggregator instance |
552 | 552 | */ |
553 | - public function createAggregator($config){ |
|
553 | + public function createAggregator($config) { |
|
554 | 554 | return $this->createReplyMessageHandler($config); |
555 | 555 | } |
556 | 556 | |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | * @param object $config configuration object for the wiretap. |
564 | 564 | * @return object the wiretap instance |
565 | 565 | */ |
566 | - public function createWiretap($config){ |
|
566 | + public function createWiretap($config) { |
|
567 | 567 | return $this->createReplyMessageHandler($config, 'Wiretap'); |
568 | 568 | } |
569 | 569 | |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | * @param string $defaultClass the class to use if none is set in config. |
577 | 577 | * @return object the reply-message-handler instance |
578 | 578 | */ |
579 | - public function createReplyMessageHandler($config, $defaultClass = false){ |
|
579 | + public function createReplyMessageHandler($config, $defaultClass = false) { |
|
580 | 580 | return $this->buildAndModify($config, $this->getReplyHandlerArguments($config), $defaultClass); |
581 | 581 | } |
582 | 582 | |
@@ -589,12 +589,12 @@ discard block |
||
589 | 589 | * @param string $defaultClass the class to use if none is set in config. |
590 | 590 | * @return object the service-activator instance |
591 | 591 | */ |
592 | - public function createServiceActivator($config, $defaultClass = false){ |
|
592 | + public function createServiceActivator($config, $defaultClass = false) { |
|
593 | 593 | $method = (string)$config['method']; |
594 | 594 | $service = $this->getService((string)$config['ref']); |
595 | - if($method && $service){ |
|
595 | + if ($method && $service) { |
|
596 | 596 | $args = $this->getReplyHandlerArguments($config); |
597 | - array_unshift($args,array( |
|
597 | + array_unshift($args, array( |
|
598 | 598 | $service, |
599 | 599 | $method |
600 | 600 | )); |
@@ -615,11 +615,11 @@ discard block |
||
615 | 615 | * @param object $config configuration object for the service. |
616 | 616 | * @return |
617 | 617 | */ |
618 | - protected function provideService($config){ |
|
618 | + protected function provideService($config) { |
|
619 | 619 | $ref = trim((string)$config['ref']); |
620 | - if($ref != ''){ |
|
620 | + if ($ref != '') { |
|
621 | 621 | $service = $this->getService($ref); |
622 | - }else{ |
|
622 | + }else { |
|
623 | 623 | $service = $this->createService($config); |
624 | 624 | } |
625 | 625 | return $service; |
@@ -636,10 +636,10 @@ discard block |
||
636 | 636 | * @param object $config configuration object for the setter-method. |
637 | 637 | * @return string camel-cased |
638 | 638 | */ |
639 | - protected static function getSetter($config){ |
|
640 | - if($config['setter']){ |
|
639 | + protected static function getSetter($config) { |
|
640 | + if ($config['setter']) { |
|
641 | 641 | $setter = (string)$config['setter']; |
642 | - }elseif($config['name']){ |
|
642 | + }elseif ($config['name']) { |
|
643 | 643 | $setter = 'set'.ucfirst((string)$config['name']); |
644 | 644 | } |
645 | 645 | return $setter; |
@@ -652,29 +652,29 @@ discard block |
||
652 | 652 | * @param object $config configuration object to create argument from. |
653 | 653 | * @return mixed build argument |
654 | 654 | */ |
655 | - protected function buildArg($config){ |
|
656 | - if(trim((string)$config['value']) != ''){ |
|
655 | + protected function buildArg($config) { |
|
656 | + if (trim((string)$config['value']) != '') { |
|
657 | 657 | $arg = (string)$config['value']; |
658 | - }elseif($config->getName() == 'value'){ |
|
658 | + }elseif ($config->getName() == 'value') { |
|
659 | 659 | $arg = (string)$config; |
660 | - }elseif($config->getName() == 'list'){ |
|
660 | + }elseif ($config->getName() == 'list') { |
|
661 | 661 | $arg = array(); |
662 | - foreach($config->children() as $entry){ |
|
663 | - if($entry->getName() == 'value'){ |
|
664 | - if($entry['key']){ |
|
662 | + foreach ($config->children() as $entry) { |
|
663 | + if ($entry->getName() == 'value') { |
|
664 | + if ($entry['key']) { |
|
665 | 665 | $arg[(string)$entry['key']] = (string)$entry; |
666 | - }else{ |
|
666 | + }else { |
|
667 | 667 | $arg[] = (string)$entry; |
668 | 668 | } |
669 | - }elseif($entry->getName() == 'service'){ |
|
669 | + }elseif ($entry->getName() == 'service') { |
|
670 | 670 | $arg[] = $this->provideService($entry); |
671 | 671 | } |
672 | 672 | } |
673 | - }elseif($config->getName() == 'service'){ |
|
673 | + }elseif ($config->getName() == 'service') { |
|
674 | 674 | $arg = $this->provideService($config); |
675 | - }elseif($config->list){ |
|
675 | + }elseif ($config->list) { |
|
676 | 676 | $arg = $this->buildArg($config->list); |
677 | - }elseif($config->service){ |
|
677 | + }elseif ($config->service) { |
|
678 | 678 | $arg = $this->buildArg($config->service); |
679 | 679 | } |
680 | 680 | return $arg; |
@@ -688,12 +688,12 @@ discard block |
||
688 | 688 | * @param object $config configuration object to create arguments from. |
689 | 689 | * @return mixed build arguments |
690 | 690 | */ |
691 | - protected function getReplyHandlerArguments($config){ |
|
691 | + protected function getReplyHandlerArguments($config) { |
|
692 | 692 | $args = array( |
693 | 693 | $this->doGetChannel('input', $config), |
694 | 694 | $this->doGetChannel('output', $config) |
695 | 695 | ); |
696 | - if($args[0] == NULL){ |
|
696 | + if ($args[0] == NULL) { |
|
697 | 697 | throw new \RuntimeException('Could not receive input channel.'); |
698 | 698 | } |
699 | 699 | return $args; |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | * @param object $config configuration object to return request-channel from. |
709 | 709 | * @return \PEIP\INF\Channel\Channel request-channel |
710 | 710 | */ |
711 | - protected function getRequestChannel($config){ |
|
711 | + protected function getRequestChannel($config) { |
|
712 | 712 | return $this->doGetChannel('request', $config); |
713 | 713 | } |
714 | 714 | |
@@ -721,7 +721,7 @@ discard block |
||
721 | 721 | * @param object $config configuration object to return reply-channel from. |
722 | 722 | * @return \PEIP\INF\Channel\Channel reply-channel |
723 | 723 | */ |
724 | - protected function getReplyChannel($config){ |
|
724 | + protected function getReplyChannel($config) { |
|
725 | 725 | return $this->doGetChannel('reply', $config); |
726 | 726 | } |
727 | 727 | |
@@ -734,15 +734,15 @@ discard block |
||
734 | 734 | * @param object $config configuration object to return channel from. |
735 | 735 | * @return \PEIP\INF\Channel\Channel reply-channel |
736 | 736 | */ |
737 | - public function doGetChannel($type, $config){ |
|
737 | + public function doGetChannel($type, $config) { |
|
738 | 738 | $channelName = $config[$type."_channel"] |
739 | 739 | ? $config[$type."_channel"] |
740 | 740 | : $config["default_".$type."_channel"]; |
741 | 741 | return $this->serviceProvider->provideService(trim((string)$channelName)); |
742 | - $channel = $this->services[trim((string)$channelName)]; |
|
743 | - if($channel instanceof \PEIP\INF\Channel\Channel){ |
|
742 | + $channel = $this->services[trim((string)$channelName)]; |
|
743 | + if ($channel instanceof \PEIP\INF\Channel\Channel) { |
|
744 | 744 | return $channel; |
745 | - }else{ |
|
745 | + }else { |
|
746 | 746 | return NULL; |
747 | 747 | } |
748 | 748 | } |
@@ -760,7 +760,7 @@ discard block |
||
760 | 760 | * @param string $defaultClass class to create instance for if none is set in config |
761 | 761 | * @return object build and modified srvice instance |
762 | 762 | */ |
763 | - public function buildAndModify($config, $arguments, $defaultClass = false){ |
|
763 | + public function buildAndModify($config, $arguments, $defaultClass = false) { |
|
764 | 764 | return ServiceFactory::buildAndModify($config, $arguments, $defaultClass); |
765 | 765 | } |
766 | 766 | |
@@ -774,21 +774,21 @@ discard block |
||
774 | 774 | * @param string $defaultClass class to create instance for if none is set in config |
775 | 775 | * @return object build and modified srvice instance |
776 | 776 | */ |
777 | - protected static function doBuild($config, $arguments, $defaultClass = false){ |
|
777 | + protected static function doBuild($config, $arguments, $defaultClass = false) { |
|
778 | 778 | $cls = $config["class"] ? trim((string)$config["class"]) : (string)$defaultClass; |
779 | - if($cls != ''){ |
|
779 | + if ($cls != '') { |
|
780 | 780 | try { |
781 | 781 | $constructor = (string)$config["constructor"]; |
782 | - if($constructor != ''){ |
|
782 | + if ($constructor != '') { |
|
783 | 783 | $service = call_user_func_array(array($cls, $constructor), $arguments); |
784 | - }else{ |
|
784 | + }else { |
|
785 | 785 | $service = self::build($cls, $arguments); |
786 | 786 | } |
787 | - }catch(\Exception $e){ |
|
787 | + } catch (\Exception $e) { |
|
788 | 788 | throw new \RuntimeException('Could not create Service "'.$cls.'" -> '.$e->getMessage()); |
789 | 789 | } |
790 | 790 | } |
791 | - if(is_object($service)){ |
|
791 | + if (is_object($service)) { |
|
792 | 792 | return $service; |
793 | 793 | } |
794 | 794 | throw new \RuntimeException('Could not create Service "'.$cls.'". Class does not exist.'); |
@@ -804,13 +804,13 @@ discard block |
||
804 | 804 | * @param array $arguments arguments for the constructor |
805 | 805 | * @return object build and modified srvice instance |
806 | 806 | */ |
807 | - protected static function build($className, $arguments){ |
|
807 | + protected static function build($className, $arguments) { |
|
808 | 808 | return GenericBuilder::getInstance($className)->build($arguments); |
809 | 809 | } |
810 | 810 | |
811 | - protected static function hasPublicProperty($service, $type, $name){ |
|
811 | + protected static function hasPublicProperty($service, $type, $name) { |
|
812 | 812 | $reflection = GenericBuilder::getInstance(get_class($service))->getReflectionClass(); |
813 | - if($reflection->{'has'.$type}($name) && $reflection->{'get'.$type}($name)->isPublic()){ |
|
813 | + if ($reflection->{'has'.$type}($name) && $reflection->{'get'.$type}($name)->isPublic()) { |
|
814 | 814 | return true; |
815 | 815 | } |
816 | 816 | 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 | } |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | $setter = self::getSetter($property); |
387 | 387 | if($setter && self::hasPublicProperty($service, 'Method', $setter)){ |
388 | 388 | $service->{$setter}($arg); |
389 | - }elseif(in_array($property, self::hasPublicProperty($service, 'Property', $setter))){ |
|
389 | + } elseif(in_array($property, self::hasPublicProperty($service, 'Property', $setter))){ |
|
390 | 390 | $service->$setter = $arg; |
391 | 391 | } |
392 | 392 | } |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | $ref = trim((string)$config['ref']); |
620 | 620 | if($ref != ''){ |
621 | 621 | $service = $this->getService($ref); |
622 | - }else{ |
|
622 | + } else{ |
|
623 | 623 | $service = $this->createService($config); |
624 | 624 | } |
625 | 625 | return $service; |
@@ -639,7 +639,7 @@ discard block |
||
639 | 639 | protected static function getSetter($config){ |
640 | 640 | if($config['setter']){ |
641 | 641 | $setter = (string)$config['setter']; |
642 | - }elseif($config['name']){ |
|
642 | + } elseif($config['name']){ |
|
643 | 643 | $setter = 'set'.ucfirst((string)$config['name']); |
644 | 644 | } |
645 | 645 | return $setter; |
@@ -655,26 +655,26 @@ discard block |
||
655 | 655 | protected function buildArg($config){ |
656 | 656 | if(trim((string)$config['value']) != ''){ |
657 | 657 | $arg = (string)$config['value']; |
658 | - }elseif($config->getName() == 'value'){ |
|
658 | + } elseif($config->getName() == 'value'){ |
|
659 | 659 | $arg = (string)$config; |
660 | - }elseif($config->getName() == 'list'){ |
|
660 | + } elseif($config->getName() == 'list'){ |
|
661 | 661 | $arg = array(); |
662 | 662 | foreach($config->children() as $entry){ |
663 | 663 | if($entry->getName() == 'value'){ |
664 | 664 | if($entry['key']){ |
665 | 665 | $arg[(string)$entry['key']] = (string)$entry; |
666 | - }else{ |
|
666 | + } else{ |
|
667 | 667 | $arg[] = (string)$entry; |
668 | 668 | } |
669 | - }elseif($entry->getName() == 'service'){ |
|
669 | + } elseif($entry->getName() == 'service'){ |
|
670 | 670 | $arg[] = $this->provideService($entry); |
671 | 671 | } |
672 | 672 | } |
673 | - }elseif($config->getName() == 'service'){ |
|
673 | + } elseif($config->getName() == 'service'){ |
|
674 | 674 | $arg = $this->provideService($config); |
675 | - }elseif($config->list){ |
|
675 | + } elseif($config->list){ |
|
676 | 676 | $arg = $this->buildArg($config->list); |
677 | - }elseif($config->service){ |
|
677 | + } elseif($config->service){ |
|
678 | 678 | $arg = $this->buildArg($config->service); |
679 | 679 | } |
680 | 680 | return $arg; |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | $channel = $this->services[trim((string)$channelName)]; |
743 | 743 | if($channel instanceof \PEIP\INF\Channel\Channel){ |
744 | 744 | return $channel; |
745 | - }else{ |
|
745 | + } else{ |
|
746 | 746 | return NULL; |
747 | 747 | } |
748 | 748 | } |
@@ -781,10 +781,10 @@ discard block |
||
781 | 781 | $constructor = (string)$config["constructor"]; |
782 | 782 | if($constructor != ''){ |
783 | 783 | $service = call_user_func_array(array($cls, $constructor), $arguments); |
784 | - }else{ |
|
784 | + } else{ |
|
785 | 785 | $service = self::build($cls, $arguments); |
786 | 786 | } |
787 | - }catch(\Exception $e){ |
|
787 | + } catch(\Exception $e){ |
|
788 | 788 | throw new \RuntimeException('Could not create Service "'.$cls.'" -> '.$e->getMessage()); |
789 | 789 | } |
790 | 790 | } |
@@ -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, |
@@ -188,7 +188,7 @@ |
||
188 | 188 | |
189 | 189 | /** |
190 | 190 | * @access protected |
191 | - * @param $commandName |
|
191 | + * @param string $commandName |
|
192 | 192 | * @param $callable |
193 | 193 | * @return |
194 | 194 | */ |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * @param $name |
65 | 65 | * @return |
66 | 66 | */ |
67 | - public function setName($name){ |
|
67 | + public function setName($name) { |
|
68 | 68 | $this->name = $name; |
69 | 69 | } |
70 | 70 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * @access public |
74 | 74 | * @return |
75 | 75 | */ |
76 | - public function getName(){ |
|
76 | + public function getName() { |
|
77 | 77 | return $this->name; |
78 | 78 | } |
79 | 79 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @param $timeout |
85 | 85 | * @return |
86 | 86 | */ |
87 | - public function send(\PEIP\INF\Message\Message $message, $timeout = -1){ |
|
87 | + public function send(\PEIP\INF\Message\Message $message, $timeout = -1) { |
|
88 | 88 | return $this->handle($message); |
89 | 89 | } |
90 | 90 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * @param $message |
95 | 95 | * @return |
96 | 96 | */ |
97 | - protected function doSend(\PEIP\INF\Message\Message $message){ |
|
97 | + protected function doSend(\PEIP\INF\Message\Message $message) { |
|
98 | 98 | $this->doFireEvent(self::EVENT_PRE_PUBLISH, array(self::HEADER_MESSAGE=>$message)); |
99 | 99 | $this->getMessageDispatcher()->notify($message); |
100 | 100 | $this->doFireEvent(self::EVENT_POST_PUBLISH, array(self::HEADER_MESSAGE=>$message)); |
@@ -107,12 +107,12 @@ discard block |
||
107 | 107 | * @param $content |
108 | 108 | * @return |
109 | 109 | */ |
110 | - protected function replyMessage($message){ |
|
110 | + protected function replyMessage($message) { |
|
111 | 111 | $message = $this->ensureMessage($message); |
112 | 112 | //if(\PEIP\Util\Test::assertMessage($message)){ |
113 | - if($this->getOutputChannel()){ |
|
113 | + if ($this->getOutputChannel()) { |
|
114 | 114 | $this->getOutputChannel()->send($message); |
115 | - }else{ |
|
115 | + }else { |
|
116 | 116 | $this->doSend($message); |
117 | 117 | } |
118 | 118 | //} |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * @param $message |
125 | 125 | * @return |
126 | 126 | */ |
127 | - protected function doReply(\PEIP\INF\Message\Message $message){ |
|
127 | + protected function doReply(\PEIP\INF\Message\Message $message) { |
|
128 | 128 | $this->replyMessage($message); |
129 | 129 | } |
130 | 130 | |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * @param $handler |
135 | 135 | * @return |
136 | 136 | */ |
137 | - public function subscribe($handler){ |
|
137 | + public function subscribe($handler) { |
|
138 | 138 | Test::ensureHandler($handler); |
139 | 139 | $this->getMessageDispatcher()->connect($handler); |
140 | 140 | $this->doFireEvent(self::EVENT_SUBSCRIBE, array(self::HEADER_SUBSCRIBER=>$handler)); |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * @param $handler e |
147 | 147 | * @return |
148 | 148 | */ |
149 | - public function unsubscribe($handler){ |
|
149 | + public function unsubscribe($handler) { |
|
150 | 150 | Test::ensureHandler($handler); |
151 | 151 | $this->getMessageDispatcher()->disconnect($handler); |
152 | 152 | $this->doFireEvent( |
@@ -164,9 +164,9 @@ discard block |
||
164 | 164 | * @param $transferListeners |
165 | 165 | * @return |
166 | 166 | */ |
167 | - public function setMessageDispatcher(\PEIP\INF\Dispatcher\Dispatcher $dispatcher, $transferListeners = true){ |
|
168 | - if(isset($this->dispatcher) && $transferListeners){ |
|
169 | - foreach($this->dispatcher->getListeners() as $listener){ |
|
167 | + public function setMessageDispatcher(\PEIP\INF\Dispatcher\Dispatcher $dispatcher, $transferListeners = true) { |
|
168 | + if (isset($this->dispatcher) && $transferListeners) { |
|
169 | + foreach ($this->dispatcher->getListeners() as $listener) { |
|
170 | 170 | $dispatcher->connect($listener); |
171 | 171 | $this->dispatcher->disconnect($listener); |
172 | 172 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * @access public |
181 | 181 | * @return |
182 | 182 | */ |
183 | - public function getMessageDispatcher(){ |
|
183 | + public function getMessageDispatcher() { |
|
184 | 184 | $defaultDispatcher = self::DEFAULT_CLASS_MESSAGE_DISPATCHER; |
185 | 185 | return isset($this->dispatcher) ? $this->dispatcher : $this->dispatcher = new $defaultDispatcher; |
186 | 186 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * @param $callable |
193 | 193 | * @return |
194 | 194 | */ |
195 | - protected function registerCommand($commandName, $callable){ |
|
195 | + protected function registerCommand($commandName, $callable) { |
|
196 | 196 | $this->commands[$commandName] = $callable; |
197 | 197 | } |
198 | 198 | |
@@ -202,10 +202,10 @@ discard block |
||
202 | 202 | * @param $cmdMessage |
203 | 203 | * @return |
204 | 204 | */ |
205 | - public function command(\PEIP\INF\Message\Message $cmdMessage){ |
|
205 | + public function command(\PEIP\INF\Message\Message $cmdMessage) { |
|
206 | 206 | $this->doFireEvent(self::EVENT_PRE_COMMAND, array(self::HEADER_MESSAGE=>$cmdMessage)); |
207 | 207 | $commandName = trim((string)$cmdMessage->getHeader('COMMAND')); |
208 | - if($commandName != '' && array_key_exists($commandName, $this->commands)){ |
|
208 | + if ($commandName != '' && array_key_exists($commandName, $this->commands)) { |
|
209 | 209 | call_user_func($this->commands[$commandName], $cmdMessage->getContent()); |
210 | 210 | } |
211 | 211 | $this->doFireEvent(self::EVENT_POST_COMMAND, array(self::HEADER_MESSAGE=>$cmdMessage)); |
@@ -112,7 +112,7 @@ |
||
112 | 112 | //if(\PEIP\Util\Test::assertMessage($message)){ |
113 | 113 | if($this->getOutputChannel()){ |
114 | 114 | $this->getOutputChannel()->send($message); |
115 | - }else{ |
|
115 | + } else{ |
|
116 | 116 | $this->doSend($message); |
117 | 117 | } |
118 | 118 | //} |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @param $discardChannel |
34 | 34 | * @return |
35 | 35 | */ |
36 | - public function setDiscardChannel(\PEIP\INF\Channel\Channel $discardChannel){ |
|
36 | + public function setDiscardChannel(\PEIP\INF\Channel\Channel $discardChannel) { |
|
37 | 37 | $this->discardChannel = $discardChannel; |
38 | 38 | } |
39 | 39 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @access public |
43 | 43 | * @return |
44 | 44 | */ |
45 | - public function getDiscardChannel(){ |
|
45 | + public function getDiscardChannel() { |
|
46 | 46 | return $this->discardChannel; |
47 | 47 | } |
48 | 48 | |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | * @param $message |
53 | 53 | * @return |
54 | 54 | */ |
55 | - protected function discardMessage(\PEIP\INF\Message\Message $message){ |
|
56 | - if(isset($this->discardChannel)){ |
|
55 | + protected function discardMessage(\PEIP\INF\Message\Message $message) { |
|
56 | + if (isset($this->discardChannel)) { |
|
57 | 57 | $this->discardChannel->send($message); |
58 | 58 | } |
59 | 59 | } |
@@ -38,12 +38,12 @@ discard block |
||
38 | 38 | * @param \PEIP\INF\Message\Message $message message to handle/reply for |
39 | 39 | * @return |
40 | 40 | */ |
41 | - public function doReply(\PEIP\INF\Message\Message $message){ |
|
41 | + public function doReply(\PEIP\INF\Message\Message $message) { |
|
42 | 42 | $res = $this->callService($message); |
43 | 43 | $out = (bool)$message->hasHeader('REPLY_CHANNEL') |
44 | 44 | ? $message->getHeader('REPLY_CHANNEL') |
45 | 45 | : $this->outputChannel; |
46 | - if($out){ |
|
46 | + if ($out) { |
|
47 | 47 | $this->replyMessage($res, $res); |
48 | 48 | } |
49 | 49 | } |
@@ -56,12 +56,12 @@ discard block |
||
56 | 56 | * @param \PEIP\INF\Message\Message $message message to call the service with it�s content/payload |
57 | 57 | * @return mixed result of calling the registered service callable with message content/payload |
58 | 58 | */ |
59 | - protected function callService(\PEIP\INF\Message\Message $message){ |
|
59 | + protected function callService(\PEIP\INF\Message\Message $message) { |
|
60 | 60 | $res = NULL; |
61 | - if(is_callable($this->serviceCallable)){ |
|
61 | + if (is_callable($this->serviceCallable)) { |
|
62 | 62 | $res = call_user_func($this->serviceCallable, $message->getContent()); |
63 | - }else{ |
|
64 | - if(is_object($this->serviceCallable) && method_exists($this->serviceCallable, 'handle')){ |
|
63 | + }else { |
|
64 | + if (is_object($this->serviceCallable) && method_exists($this->serviceCallable, 'handle')) { |
|
65 | 65 | $res = $this->serviceCallable->handle($message->getContent()); |
66 | 66 | } |
67 | 67 | } |
@@ -17,7 +17,7 @@ |
||
17 | 17 | protected function getMessage($object){ |
18 | 18 | if($this->channel instanceof \PEIP\INF\Channel\SubscribableChannel){ |
19 | 19 | return $object; |
20 | - }else{ |
|
20 | + } else{ |
|
21 | 21 | return $object->getContent()->receive(); |
22 | 22 | } |
23 | 23 | } |
@@ -15,11 +15,11 @@ discard block |
||
15 | 15 | class Test { |
16 | 16 | |
17 | 17 | |
18 | - public static function assertClassHasConstructor($className){ |
|
19 | - return (boolean) ReflectionPool::getInstance($className)->getConstructor(); |
|
18 | + public static function assertClassHasConstructor($className) { |
|
19 | + return (boolean)ReflectionPool::getInstance($className)->getConstructor(); |
|
20 | 20 | } |
21 | 21 | |
22 | - public static function assertRequiredConstructorParameters($className, $parameters){ |
|
22 | + public static function assertRequiredConstructorParameters($className, $parameters) { |
|
23 | 23 | return (boolean) |
24 | 24 | !self::assertClassHasConstructor($className) || |
25 | 25 | count($parameters) >= ReflectionPool::getInstance($className) |
@@ -27,55 +27,55 @@ discard block |
||
27 | 27 | ->getNumberOfRequiredParameters(); |
28 | 28 | } |
29 | 29 | |
30 | - public static function assertInstanceOf($className, $object){ |
|
31 | - return (boolean) ReflectionPool::getInstance($className) |
|
30 | + public static function assertInstanceOf($className, $object) { |
|
31 | + return (boolean)ReflectionPool::getInstance($className) |
|
32 | 32 | ->isInstance($object); |
33 | 33 | } |
34 | 34 | |
35 | - public static function assertClassOrInterfaceExists($className){ |
|
36 | - return (boolean) class_exists($className) || interface_exists($className); |
|
35 | + public static function assertClassOrInterfaceExists($className) { |
|
36 | + return (boolean)class_exists($className) || interface_exists($className); |
|
37 | 37 | } |
38 | 38 | |
39 | - public static function assertImplements($className, $interfaceName){ |
|
39 | + public static function assertImplements($className, $interfaceName) { |
|
40 | 40 | $className = is_object($className) ? get_class($className) : $className; |
41 | - $res = false;//throw new \Exception(); |
|
41 | + $res = false; //throw new \Exception(); |
|
42 | 42 | try { |
43 | 43 | class_exists($className); |
44 | - $res = ReflectionPool::getInstance($className) |
|
44 | + $res = ReflectionPool::getInstance($className) |
|
45 | 45 | ->implementsInterface($interfaceName); |
46 | - } catch (\Exception $e){ |
|
46 | + } catch (\Exception $e) { |
|
47 | 47 | $res = false; |
48 | 48 | } |
49 | - return $res;; |
|
49 | + return $res; ; |
|
50 | 50 | } |
51 | 51 | |
52 | - public static function assertMessage($message){ |
|
52 | + public static function assertMessage($message) { |
|
53 | 53 | return self::assertImplements($message, '\PEIP\INF\Message\Message'); |
54 | 54 | } |
55 | 55 | |
56 | - public static function assertEvent($event){ |
|
56 | + public static function assertEvent($event) { |
|
57 | 57 | return self::assertImplements($event, '\PEIP\INF\Event\Event'); |
58 | 58 | } |
59 | 59 | |
60 | - public static function assertEventSubject($event){ |
|
60 | + public static function assertEventSubject($event) { |
|
61 | 61 | return self::assertImplements($event, '\PEIP\INF\Event\Event') |
62 | 62 | && $event->getSubject(); |
63 | 63 | } |
64 | 64 | |
65 | - public static function assertEventObjectSubject($event){ |
|
65 | + public static function assertEventObjectSubject($event) { |
|
66 | 66 | return self::assertEventSubject($event) |
67 | 67 | && is_object($event->getSubject()); |
68 | 68 | } |
69 | - public static function assertArrayAccess($var){ |
|
70 | - return (boolean) is_array($var) || $var instanceof \ArrayAccess; |
|
69 | + public static function assertArrayAccess($var) { |
|
70 | + return (boolean)is_array($var) || $var instanceof \ArrayAccess; |
|
71 | 71 | } |
72 | 72 | |
73 | - public static function assertHandler($var){ |
|
74 | - return (boolean) is_callable($var) || $var instanceof \PEIP\INF\Handler\Handler; |
|
73 | + public static function assertHandler($var) { |
|
74 | + return (boolean)is_callable($var) || $var instanceof \PEIP\INF\Handler\Handler; |
|
75 | 75 | } |
76 | 76 | |
77 | - public static function castType($var, $type){ |
|
78 | - switch($type){ |
|
77 | + public static function castType($var, $type) { |
|
78 | + switch ($type) { |
|
79 | 79 | case 'string': |
80 | 80 | $var = (string)$var; |
81 | 81 | break; |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | return $var; |
100 | 100 | } |
101 | 101 | |
102 | - public static function ensureArrayAccess($var){ |
|
103 | - if(!Test::assertArrayAccess($var)){ |
|
102 | + public static function ensureArrayAccess($var) { |
|
103 | + if (!Test::assertArrayAccess($var)) { |
|
104 | 104 | throw new \InvalidArgumentException( |
105 | 105 | 'Value is not an array nor an instance of ArrayAccess' |
106 | 106 | ); |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | } |
110 | 110 | |
111 | 111 | |
112 | - public static function ensureHandler($var){ |
|
113 | - if(!Test::assertHandler($var)){ |
|
112 | + public static function ensureHandler($var) { |
|
113 | + if (!Test::assertHandler($var)) { |
|
114 | 114 | throw new \InvalidArgumentException( |
115 | 115 | 'Value is not an callable nor an instance of \PEIP\INF\Handler\Handler' |
116 | 116 | ); |
@@ -118,8 +118,8 @@ discard block |
||
118 | 118 | return $var; |
119 | 119 | } |
120 | 120 | |
121 | - public static function ensureImplements($className, $interfaceName){ |
|
122 | - if(!Test::assertImplements($className, $interfaceName)){ |
|
121 | + public static function ensureImplements($className, $interfaceName) { |
|
122 | + if (!Test::assertImplements($className, $interfaceName)) { |
|
123 | 123 | throw new \InvalidArgumentException( |
124 | 124 | 'Class "'.$className.'" is not an instanceof "'.$interfaceName.'"' |
125 | 125 | ); |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | return $className; |
128 | 128 | } |
129 | 129 | |
130 | - public static function assertMethod($className, $methodname){ |
|
130 | + public static function assertMethod($className, $methodname) { |
|
131 | 131 | return ReflectionPool::getInstance($className)->hasMethod($methodname); |
132 | 132 | } |
133 | 133 |
@@ -43,7 +43,7 @@ |
||
43 | 43 | class_exists($className); |
44 | 44 | $res = ReflectionPool::getInstance($className) |
45 | 45 | ->implementsInterface($interfaceName); |
46 | - } catch (\Exception $e){ |
|
46 | + } catch (\Exception $e){ |
|
47 | 47 | $res = false; |
48 | 48 | } |
49 | 49 | return $res;; |
@@ -22,6 +22,6 @@ |
||
22 | 22 | |
23 | 23 | interface Singleton { |
24 | 24 | |
25 | - public static function getInstance (); |
|
25 | + public static function getInstance(); |
|
26 | 26 | |
27 | 27 | } |