@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @param $className |
34 | 34 | * @return |
35 | 35 | */ |
36 | - public function __construct($className){ |
|
36 | + public function __construct($className) { |
|
37 | 37 | $this->className = $className; |
38 | 38 | } |
39 | 39 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @param $message |
44 | 44 | * @return |
45 | 45 | */ |
46 | - public function acceptMessage(\PEIP\INF\Message\Message $message){ |
|
46 | + public function acceptMessage(\PEIP\INF\Message\Message $message) { |
|
47 | 47 | return $message->getContent() instanceof $className; |
48 | 48 | } |
49 | 49 |
@@ -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 |
@@ -22,18 +22,17 @@ |
||
22 | 22 | */ |
23 | 23 | |
24 | 24 | |
25 | -use PEIP\Handler\CallableHandler; |
|
26 | -use PEIP\Service\HeaderServiceActivator; |
|
27 | -use PEIP\Channel\ChannelRegistry; |
|
28 | -use PEIP\Service\ServiceProvider; |
|
29 | -use PEIP\Plugins\BasePlugin; |
|
30 | -use PEIP\Factory\ServiceFactory; |
|
31 | -use PEIP\Base\GenericBuilder; |
|
32 | -use PEIP\Channel\PollableChannel; |
|
33 | -use PEIP\Channel\PublishSubscribeChannel; |
|
34 | -use PEIP\Gateway\SimpleMessagingGateway; |
|
35 | -use PEIP\Listener\Wiretap; |
|
36 | -use PEIP\Service\ServiceActivator; |
|
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 | +use PEIP\Channel\PollableChannel; |
|
32 | +use PEIP\Channel\PublishSubscribeChannel; |
|
33 | +use PEIP\Gateway\SimpleMessagingGateway; |
|
34 | +use PEIP\Listener\Wiretap; |
|
35 | +use PEIP\Service\ServiceActivator; |
|
37 | 36 | use PEIP\Context\XMLContextReader; |
38 | 37 | |
39 | 38 | class XMLContext |
@@ -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(array $config){ |
369 | 368 | return ServiceFactory::createService($config); |
@@ -638,7 +637,7 @@ discard block |
||
638 | 637 | * |
639 | 638 | * @access protected |
640 | 639 | * @param object $config configuration object to create arguments from. |
641 | - * @return mixed build arguments |
|
640 | + * @return \PEIP\INF\Channel\Channel[] build arguments |
|
642 | 641 | */ |
643 | 642 | protected function getReplyHandlerArguments($config){ |
644 | 643 | $args = array( |
@@ -683,7 +682,8 @@ discard block |
||
683 | 682 | * |
684 | 683 | * @access protected |
685 | 684 | * @param string the configuration type ofthe channel (e.g.: 'reply', 'request') |
686 | - * @param object $config configuration object to return channel from. |
|
685 | + * @param object $config configuration object to return channel from. |
|
686 | + * @param string $type |
|
687 | 687 | * @return \PEIP\INF\Channel\Channel reply-channel |
688 | 688 | */ |
689 | 689 | public function doGetChannel($type, $config){ |
@@ -737,7 +737,7 @@ discard block |
||
737 | 737 | * @see GenericBuilder |
738 | 738 | * @static |
739 | 739 | * @access protected |
740 | - * @param object $className name of class to build instance for. |
|
740 | + * @param string $className name of class to build instance for. |
|
741 | 741 | * @param array $arguments arguments for the constructor |
742 | 742 | * @return object build and modified srvice instance |
743 | 743 | */ |
@@ -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 | /** |
@@ -56,24 +56,24 @@ discard block |
||
56 | 56 | * @param string $string the configuration string |
57 | 57 | * @return |
58 | 58 | */ |
59 | - public function __construct($string){ |
|
59 | + public function __construct($string) { |
|
60 | 60 | $this->initNodeBuilders(); |
61 | 61 | $reader = new XMLContextReader($string); |
62 | 62 | |
63 | 63 | |
64 | 64 | $serviceActivator = new HeaderServiceActivator(array($this, 'addConfig'), 'NODE'); |
65 | 65 | |
66 | - $reader->connect('read_node', $serviceActivator); |
|
66 | + $reader->connect('read_node', $serviceActivator); |
|
67 | 67 | $reader->read(); |
68 | 68 | |
69 | 69 | |
70 | 70 | } |
71 | 71 | |
72 | - public function addConfig($config){ |
|
72 | + public function addConfig($config) { |
|
73 | 73 | return $this->getServiceProvider()->addConfig($config); |
74 | 74 | } |
75 | 75 | |
76 | - public function handleReadConfig(\PEIP\INF\Event\Event $event){ |
|
76 | + public function handleReadConfig(\PEIP\INF\Event\Event $event) { |
|
77 | 77 | $this->addConfig($event->getHeader('NODE')); |
78 | 78 | } |
79 | 79 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * @return XMLContext the context instance |
86 | 86 | * @throws RuntimeException |
87 | 87 | */ |
88 | - public static function createFromString($string){ |
|
88 | + public static function createFromString($string) { |
|
89 | 89 | return new XMLContext($string); |
90 | 90 | } |
91 | 91 | |
@@ -97,10 +97,10 @@ discard block |
||
97 | 97 | * @return XMLContext the context instance |
98 | 98 | * @throws RuntimeException |
99 | 99 | */ |
100 | - public static function createFromFile($file){ |
|
101 | - if(file_exists($file)){ |
|
100 | + public static function createFromFile($file) { |
|
101 | + if (file_exists($file)) { |
|
102 | 102 | return self::createFromString(file_get_contents($file)); |
103 | - }else{ |
|
103 | + }else { |
|
104 | 104 | throw new \RuntimeException('Cannot open file "'.$file.'".'); |
105 | 105 | } |
106 | 106 | } |
@@ -111,15 +111,15 @@ discard block |
||
111 | 111 | * @access protected |
112 | 112 | * @return void |
113 | 113 | */ |
114 | - protected function init(){ |
|
114 | + protected function init() { |
|
115 | 115 | $xml = $this->simpleXML; |
116 | 116 | $this->channelRegistry = ChannelRegistry::getInstance(); |
117 | 117 | // register this context as a service if id is set. |
118 | - if($xml['id']){ |
|
118 | + if ($xml['id']) { |
|
119 | 119 | $this->services[(string)$xml['id']] = $this; |
120 | 120 | } |
121 | 121 | // build services |
122 | - foreach($xml->children() as $entry){ |
|
122 | + foreach ($xml->children() as $entry) { |
|
123 | 123 | $this->buildNode($entry); |
124 | 124 | } |
125 | 125 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | * @param string $nodeName the name of the node |
133 | 133 | * @param callable $callable a callable which creates instances for node-name |
134 | 134 | */ |
135 | - public function registerNodeBuilder($nodeName, $callable){ |
|
135 | + public function registerNodeBuilder($nodeName, $callable) { |
|
136 | 136 | return $this->getServiceProvider()->registerNodeBuilder($nodeName, $callable); |
137 | 137 | } |
138 | 138 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @access public |
144 | 144 | * @param \PEIP\INF\Context\Context_Plugin $plugin a plugin instance |
145 | 145 | */ |
146 | - public function addPlugin(\PEIP\INF\Context\ContextPlugin $plugin){ |
|
146 | + public function addPlugin(\PEIP\INF\Context\ContextPlugin $plugin) { |
|
147 | 147 | $plugin->init($this); |
148 | 148 | } |
149 | 149 | |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | * @param array $config configuration for the plugin |
155 | 155 | * @return |
156 | 156 | */ |
157 | - public function createPlugin(array $config){ |
|
157 | + public function createPlugin(array $config) { |
|
158 | 158 | $plugin = $this->createService($config); |
159 | 159 | $this->addPlugin($plugin); |
160 | 160 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | * @access public |
176 | 176 | * @param XMLContext $config the config to include |
177 | 177 | */ |
178 | - public function includeContext(XMLContext $context){ |
|
178 | + public function includeContext(XMLContext $context) { |
|
179 | 179 | $this->services = array_merge($this->services, $context->getServices()); |
180 | 180 | } |
181 | 181 | |
@@ -186,8 +186,8 @@ discard block |
||
186 | 186 | * @access public |
187 | 187 | * @param XMLContext $context the config to include |
188 | 188 | */ |
189 | - public function includeContextFromFile($filePath){ |
|
190 | - if(file_exists($filePath)){ |
|
189 | + public function includeContextFromFile($filePath) { |
|
190 | + if (file_exists($filePath)) { |
|
191 | 191 | $this->includeContextFromString(file_get_contents($filePath)); |
192 | 192 | } |
193 | 193 | } |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | * @access public |
200 | 200 | * @param string $configString the config to include |
201 | 201 | */ |
202 | - public function includeContextFromString($configString){ |
|
202 | + public function includeContextFromString($configString) { |
|
203 | 203 | $context = new XMLContext($configString); |
204 | 204 | $this->includeContext($context); |
205 | 205 | } |
@@ -211,14 +211,14 @@ discard block |
||
211 | 211 | * @access protected |
212 | 212 | * @param object $config the configuration for the context |
213 | 213 | */ |
214 | - protected function createContext($config){ |
|
215 | - if((string)$config['file'] != ''){ |
|
214 | + protected function createContext($config) { |
|
215 | + if ((string)$config['file'] != '') { |
|
216 | 216 | $this->includeContextFromFile((string)$config['file']); |
217 | 217 | } |
218 | 218 | } |
219 | 219 | |
220 | 220 | |
221 | - public function getServiceProvider(){ |
|
221 | + public function getServiceProvider() { |
|
222 | 222 | return isset($this->serviceProvider) |
223 | 223 | ? $this->serviceProvider |
224 | 224 | : $this->serviceProvider = new ServiceProvider(); |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | * @see XMLContext::includeContext |
235 | 235 | * @access protected |
236 | 236 | */ |
237 | - protected function initNodeBuilders(){ |
|
237 | + protected function initNodeBuilders() { |
|
238 | 238 | $builders = array( |
239 | 239 | 'include' => 'createContext', |
240 | 240 | 'plugin' => 'createPlugin', |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | ); |
253 | 253 | $plugin = new BasePlugin(); |
254 | 254 | $this->addPlugin($plugin); return; |
255 | - foreach($builders as $nodeName => $method){ |
|
255 | + foreach ($builders as $nodeName => $method) { |
|
256 | 256 | $this->registerNodeBuilder($nodeName, array($this, $method)); |
257 | 257 | } |
258 | 258 | } |
@@ -266,10 +266,10 @@ discard block |
||
266 | 266 | * @param object $node configuration-node |
267 | 267 | * @return void |
268 | 268 | */ |
269 | - protected function buildNode($node){ |
|
269 | + protected function buildNode($node) { |
|
270 | 270 | $nodeName = $node->getName(); |
271 | 271 | // call the builder method registered for the node. |
272 | - if(array_key_exists($nodeName, $this->nodeBuilders)){ |
|
272 | + if (array_key_exists($nodeName, $this->nodeBuilders)) { |
|
273 | 273 | call_user_func($this->nodeBuilders[$nodeName], $node); |
274 | 274 | } |
275 | 275 | } |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | * @param string $channelName the name/id of the channel to return |
289 | 289 | * @return \PEIP\INF\Channel\Channel |
290 | 290 | */ |
291 | - public function resolveChannelName($channelName){ |
|
291 | + public function resolveChannelName($channelName) { |
|
292 | 292 | return $this->channelRegistry->get($channelName); |
293 | 293 | } |
294 | 294 | |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | * @param mixed $id the id for the service |
301 | 301 | * @return object the service instance if found |
302 | 302 | */ |
303 | - public function getService($id){ |
|
303 | + public function getService($id) { |
|
304 | 304 | return $this->getServiceProvider()->provideService($id); |
305 | 305 | } |
306 | 306 | |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | * @access public |
311 | 311 | * @return array registered services |
312 | 312 | */ |
313 | - public function getServices(){ |
|
313 | + public function getServices() { |
|
314 | 314 | return $this->getServiceProvider()->getServices(); |
315 | 315 | } |
316 | 316 | |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | * @param mixed $id the id for the service |
322 | 322 | * @return boolean wether service is registered |
323 | 323 | */ |
324 | - public function hasService($id){ |
|
324 | + public function hasService($id) { |
|
325 | 325 | return isset($this->services[$id]); |
326 | 326 | } |
327 | 327 | |
@@ -335,9 +335,9 @@ discard block |
||
335 | 335 | * @return object the service instance if found |
336 | 336 | * |
337 | 337 | */ |
338 | - protected function requestService($id){ |
|
338 | + protected function requestService($id) { |
|
339 | 339 | $service = $this->getService($id); |
340 | - if($service === NULL){ |
|
340 | + if ($service === NULL) { |
|
341 | 341 | throw new \RuntimeException('Service "'.$id.'" not found.'); |
342 | 342 | } |
343 | 343 | return $service; |
@@ -351,9 +351,9 @@ discard block |
||
351 | 351 | * @param object $config |
352 | 352 | * @return object the initialized service instance |
353 | 353 | */ |
354 | - protected function initService($config){ |
|
354 | + protected function initService($config) { |
|
355 | 355 | $id = trim((string)$config['id']); |
356 | - if($id != ''){ |
|
356 | + if ($id != '') { |
|
357 | 357 | return $this->services[$id] = $this->createService($config); |
358 | 358 | } |
359 | 359 | } |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | * @param $config |
366 | 366 | * @return object the initialized service instance |
367 | 367 | */ |
368 | - public function createService(array $config){ |
|
368 | + public function createService(array $config) { |
|
369 | 369 | return ServiceFactory::createService($config); |
370 | 370 | } |
371 | 371 | |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | * @param mixed $id the id ofthe gateway |
380 | 380 | * @return object the gateway instance |
381 | 381 | */ |
382 | - public function getGateway($id){ |
|
382 | + public function getGateway($id) { |
|
383 | 383 | return $this->getServiceProvider()->provideService($id); |
384 | 384 | } |
385 | 385 | |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | * @param object $config configuration object for the pollable channel. |
392 | 392 | * @return \PEIP\INF\Channel\Channel the created pollable channel instance |
393 | 393 | */ |
394 | - public function createChannel($config){ |
|
394 | + public function createChannel($config) { |
|
395 | 395 | return $this->doCreateChannel($config, 'PollableChannel'); |
396 | 396 | } |
397 | 397 | |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | * @param object $config configuration object for the subscribable channel. |
404 | 404 | * @return \PEIP\INF\Channel\Channel the created subscribable channel instance |
405 | 405 | */ |
406 | - public function createSubscribableChannel($config){ |
|
406 | + public function createSubscribableChannel($config) { |
|
407 | 407 | return $this->doCreateChannel($config, 'PublishSubscribeChannel'); |
408 | 408 | } |
409 | 409 | |
@@ -416,9 +416,9 @@ discard block |
||
416 | 416 | * @param $additionalArguments additional arguments for the channel constructor (without first arg = id) |
417 | 417 | * @return \PEIP\INF\Channel\Channel the created channel instance |
418 | 418 | */ |
419 | - public function doCreateChannel($config, $defaultChannelClass, array $additionalArguments = array()){ |
|
419 | + public function doCreateChannel($config, $defaultChannelClass, array $additionalArguments = array()) { |
|
420 | 420 | $id = (string)$config['id']; |
421 | - if($id != ''){ |
|
421 | + if ($id != '') { |
|
422 | 422 | array_unshift($additionalArguments, $id); |
423 | 423 | $channel = ServiceFactory::buildAndModify($config, $additionalArguments, $defaultChannelClass); |
424 | 424 | $this->channelRegistry->register($channel); |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | * @param string $defaultClass the class to use if none is set in config. |
436 | 436 | * @return object the gateway instance |
437 | 437 | */ |
438 | - public function createGateway($config, $defaultClass = false){ |
|
438 | + public function createGateway($config, $defaultClass = false) { |
|
439 | 439 | $args = array( |
440 | 440 | $this->getRequestChannel($config), |
441 | 441 | $this->getReplyChannel($config) |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | * @param string $defaultClass the class to use if none is set in config. |
460 | 460 | * @return object the router instance |
461 | 461 | */ |
462 | - public function createRouter($config, $defaultClass = false){ |
|
462 | + public function createRouter($config, $defaultClass = false) { |
|
463 | 463 | $resolver = $config['channel_resolver'] ? (string)$config['channel_resolver'] : $this->channelRegistry; |
464 | 464 | return ServiceFactory::buildAndModify($config, array( |
465 | 465 | $resolver, |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | * @param object $config configuration object for the splitter. |
477 | 477 | * @return object the splitter instance |
478 | 478 | */ |
479 | - public function createSplitter($config){ |
|
479 | + public function createSplitter($config) { |
|
480 | 480 | return $this->createReplyMessageHandler($config); |
481 | 481 | } |
482 | 482 | |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | * @param object $config configuration object for the transformer. |
490 | 490 | * @return object the transformer instance |
491 | 491 | */ |
492 | - public function createTransformer($config){ |
|
492 | + public function createTransformer($config) { |
|
493 | 493 | return $this->createReplyMessageHandler($config); |
494 | 494 | } |
495 | 495 | |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | * @param object $config configuration object for the aggregator. |
503 | 503 | * @return object the aggregator instance |
504 | 504 | */ |
505 | - public function createAggregator($config){ |
|
505 | + public function createAggregator($config) { |
|
506 | 506 | return $this->createReplyMessageHandler($config); |
507 | 507 | } |
508 | 508 | |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | * @param object $config configuration object for the wiretap. |
516 | 516 | * @return object the wiretap instance |
517 | 517 | */ |
518 | - public function createWiretap($config){ |
|
518 | + public function createWiretap($config) { |
|
519 | 519 | return $this->createReplyMessageHandler($config, 'Wiretap'); |
520 | 520 | } |
521 | 521 | |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | * @param string $defaultClass the class to use if none is set in config. |
529 | 529 | * @return object the reply-message-handler instance |
530 | 530 | */ |
531 | - public function createReplyMessageHandler($config, $defaultClass = false){ |
|
531 | + public function createReplyMessageHandler($config, $defaultClass = false) { |
|
532 | 532 | return ServiceFactory::buildAndModify($config, $this->getReplyHandlerArguments($config), $defaultClass); |
533 | 533 | } |
534 | 534 | |
@@ -541,12 +541,12 @@ discard block |
||
541 | 541 | * @param string $defaultClass the class to use if none is set in config. |
542 | 542 | * @return object the service-activator instance |
543 | 543 | */ |
544 | - public function createServiceActivator($config, $defaultClass = false){ |
|
544 | + public function createServiceActivator($config, $defaultClass = false) { |
|
545 | 545 | $method = (string)$config['method']; |
546 | 546 | $service = $this->getService((string)$config['ref']); |
547 | - if($method && $service){ |
|
547 | + if ($method && $service) { |
|
548 | 548 | $args = $this->getReplyHandlerArguments($config); |
549 | - array_unshift($args,array( |
|
549 | + array_unshift($args, array( |
|
550 | 550 | $service, |
551 | 551 | $method |
552 | 552 | )); |
@@ -567,11 +567,11 @@ discard block |
||
567 | 567 | * @param object $config configuration object for the service. |
568 | 568 | * @return |
569 | 569 | */ |
570 | - protected function provideService($config){ |
|
570 | + protected function provideService($config) { |
|
571 | 571 | $ref = trim((string)$config['ref']); |
572 | - if($ref != ''){ |
|
572 | + if ($ref != '') { |
|
573 | 573 | $service = $this->getService($ref); |
574 | - }else{ |
|
574 | + }else { |
|
575 | 575 | $service = $this->createService($config); |
576 | 576 | } |
577 | 577 | return $service; |
@@ -588,10 +588,10 @@ discard block |
||
588 | 588 | * @param object $config configuration object for the setter-method. |
589 | 589 | * @return string camel-cased |
590 | 590 | */ |
591 | - protected static function getSetter($config){ |
|
592 | - if($config['setter']){ |
|
591 | + protected static function getSetter($config) { |
|
592 | + if ($config['setter']) { |
|
593 | 593 | $setter = (string)$config['setter']; |
594 | - }elseif($config['name']){ |
|
594 | + }elseif ($config['name']) { |
|
595 | 595 | $setter = 'set'.ucfirst((string)$config['name']); |
596 | 596 | } |
597 | 597 | return $setter; |
@@ -604,29 +604,29 @@ discard block |
||
604 | 604 | * @param object $config configuration object to create argument from. |
605 | 605 | * @return mixed build argument |
606 | 606 | */ |
607 | - protected function buildArg($config){ |
|
608 | - if(trim((string)$config['value']) != ''){ |
|
607 | + protected function buildArg($config) { |
|
608 | + if (trim((string)$config['value']) != '') { |
|
609 | 609 | $arg = (string)$config['value']; |
610 | - }elseif($config->getName() == 'value'){ |
|
610 | + }elseif ($config->getName() == 'value') { |
|
611 | 611 | $arg = (string)$config; |
612 | - }elseif($config->getName() == 'list'){ |
|
612 | + }elseif ($config->getName() == 'list') { |
|
613 | 613 | $arg = array(); |
614 | - foreach($config->children() as $entry){ |
|
615 | - if($entry->getName() == 'value'){ |
|
616 | - if($entry['key']){ |
|
614 | + foreach ($config->children() as $entry) { |
|
615 | + if ($entry->getName() == 'value') { |
|
616 | + if ($entry['key']) { |
|
617 | 617 | $arg[(string)$entry['key']] = (string)$entry; |
618 | - }else{ |
|
618 | + }else { |
|
619 | 619 | $arg[] = (string)$entry; |
620 | 620 | } |
621 | - }elseif($entry->getName() == 'service'){ |
|
621 | + }elseif ($entry->getName() == 'service') { |
|
622 | 622 | $arg[] = $this->provideService($entry); |
623 | 623 | } |
624 | 624 | } |
625 | - }elseif($config->getName() == 'service'){ |
|
625 | + }elseif ($config->getName() == 'service') { |
|
626 | 626 | $arg = $this->provideService($config); |
627 | - }elseif($config->list){ |
|
627 | + }elseif ($config->list) { |
|
628 | 628 | $arg = $this->buildArg($config->list); |
629 | - }elseif($config->service){ |
|
629 | + }elseif ($config->service) { |
|
630 | 630 | $arg = $this->buildArg($config->service); |
631 | 631 | } |
632 | 632 | return $arg; |
@@ -640,12 +640,12 @@ discard block |
||
640 | 640 | * @param object $config configuration object to create arguments from. |
641 | 641 | * @return mixed build arguments |
642 | 642 | */ |
643 | - protected function getReplyHandlerArguments($config){ |
|
643 | + protected function getReplyHandlerArguments($config) { |
|
644 | 644 | $args = array( |
645 | 645 | $this->doGetChannel('input', $config), |
646 | 646 | $this->doGetChannel('output', $config) |
647 | 647 | ); |
648 | - if($args[0] == NULL){ |
|
648 | + if ($args[0] == NULL) { |
|
649 | 649 | throw new \RuntimeException('Could not receive input channel.'); |
650 | 650 | } |
651 | 651 | return $args; |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | * @param object $config configuration object to return request-channel from. |
661 | 661 | * @return \PEIP\INF\Channel\Channel request-channel |
662 | 662 | */ |
663 | - protected function getRequestChannel($config){ |
|
663 | + protected function getRequestChannel($config) { |
|
664 | 664 | return $this->doGetChannel('request', $config); |
665 | 665 | } |
666 | 666 | |
@@ -673,7 +673,7 @@ discard block |
||
673 | 673 | * @param object $config configuration object to return reply-channel from. |
674 | 674 | * @return \PEIP\INF\Channel\Channel reply-channel |
675 | 675 | */ |
676 | - protected function getReplyChannel($config){ |
|
676 | + protected function getReplyChannel($config) { |
|
677 | 677 | return $this->doGetChannel('reply', $config); |
678 | 678 | } |
679 | 679 | |
@@ -686,15 +686,15 @@ discard block |
||
686 | 686 | * @param object $config configuration object to return channel from. |
687 | 687 | * @return \PEIP\INF\Channel\Channel reply-channel |
688 | 688 | */ |
689 | - public function doGetChannel($type, $config){ |
|
689 | + public function doGetChannel($type, $config) { |
|
690 | 690 | $channelName = $config[$type."_channel"] |
691 | 691 | ? $config[$type."_channel"] |
692 | 692 | : $config["default_".$type."_channel"]; |
693 | 693 | return $this->serviceProvider->provideService(trim((string)$channelName)); |
694 | - $channel = $this->services[trim((string)$channelName)]; |
|
695 | - if($channel instanceof \PEIP\INF\Channel\Channel){ |
|
694 | + $channel = $this->services[trim((string)$channelName)]; |
|
695 | + if ($channel instanceof \PEIP\INF\Channel\Channel) { |
|
696 | 696 | return $channel; |
697 | - }else{ |
|
697 | + }else { |
|
698 | 698 | return NULL; |
699 | 699 | } |
700 | 700 | } |
@@ -711,21 +711,21 @@ discard block |
||
711 | 711 | * @param string $defaultClass class to create instance for if none is set in config |
712 | 712 | * @return object build and modified srvice instance |
713 | 713 | */ |
714 | - protected static function doBuild($config, $arguments, $defaultClass = false){ |
|
714 | + protected static function doBuild($config, $arguments, $defaultClass = false) { |
|
715 | 715 | $cls = $config["class"] ? trim((string)$config["class"]) : (string)$defaultClass; |
716 | - if($cls != ''){ |
|
716 | + if ($cls != '') { |
|
717 | 717 | try { |
718 | 718 | $constructor = (string)$config["constructor"]; |
719 | - if($constructor != ''){ |
|
719 | + if ($constructor != '') { |
|
720 | 720 | $service = call_user_func_array(array($cls, $constructor), $arguments); |
721 | - }else{ |
|
721 | + }else { |
|
722 | 722 | $service = self::build($cls, $arguments); |
723 | 723 | } |
724 | - }catch(\Exception $e){ |
|
724 | + } catch (\Exception $e) { |
|
725 | 725 | throw new \RuntimeException('Could not create Service "'.$cls.'" -> '.$e->getMessage()); |
726 | 726 | } |
727 | 727 | } |
728 | - if(is_object($service)){ |
|
728 | + if (is_object($service)) { |
|
729 | 729 | return $service; |
730 | 730 | } |
731 | 731 | throw new \RuntimeException('Could not create Service "'.$cls.'". Class does not exist.'); |
@@ -741,13 +741,13 @@ discard block |
||
741 | 741 | * @param array $arguments arguments for the constructor |
742 | 742 | * @return object build and modified srvice instance |
743 | 743 | */ |
744 | - protected static function build($className, $arguments){ |
|
744 | + protected static function build($className, $arguments) { |
|
745 | 745 | return GenericBuilder::getInstance($className)->build($arguments); |
746 | 746 | } |
747 | 747 | |
748 | - protected static function hasPublicProperty($service, $type, $name){ |
|
748 | + protected static function hasPublicProperty($service, $type, $name) { |
|
749 | 749 | $reflection = GenericBuilder::getInstance(get_class($service))->getReflectionClass(); |
750 | - if($reflection->{'has'.$type}($name) && $reflection->{'get'.$type}($name)->isPublic()){ |
|
750 | + if ($reflection->{'has'.$type}($name) && $reflection->{'get'.$type}($name)->isPublic()) { |
|
751 | 751 | return true; |
752 | 752 | } |
753 | 753 | return false; |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | public static function createFromFile($file){ |
101 | 101 | if(file_exists($file)){ |
102 | 102 | return self::createFromString(file_get_contents($file)); |
103 | - }else{ |
|
103 | + } else{ |
|
104 | 104 | throw new \RuntimeException('Cannot open file "'.$file.'".'); |
105 | 105 | } |
106 | 106 | } |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | $ref = trim((string)$config['ref']); |
572 | 572 | if($ref != ''){ |
573 | 573 | $service = $this->getService($ref); |
574 | - }else{ |
|
574 | + } else{ |
|
575 | 575 | $service = $this->createService($config); |
576 | 576 | } |
577 | 577 | return $service; |
@@ -591,7 +591,7 @@ discard block |
||
591 | 591 | protected static function getSetter($config){ |
592 | 592 | if($config['setter']){ |
593 | 593 | $setter = (string)$config['setter']; |
594 | - }elseif($config['name']){ |
|
594 | + } elseif($config['name']){ |
|
595 | 595 | $setter = 'set'.ucfirst((string)$config['name']); |
596 | 596 | } |
597 | 597 | return $setter; |
@@ -607,26 +607,26 @@ discard block |
||
607 | 607 | protected function buildArg($config){ |
608 | 608 | if(trim((string)$config['value']) != ''){ |
609 | 609 | $arg = (string)$config['value']; |
610 | - }elseif($config->getName() == 'value'){ |
|
610 | + } elseif($config->getName() == 'value'){ |
|
611 | 611 | $arg = (string)$config; |
612 | - }elseif($config->getName() == 'list'){ |
|
612 | + } elseif($config->getName() == 'list'){ |
|
613 | 613 | $arg = array(); |
614 | 614 | foreach($config->children() as $entry){ |
615 | 615 | if($entry->getName() == 'value'){ |
616 | 616 | if($entry['key']){ |
617 | 617 | $arg[(string)$entry['key']] = (string)$entry; |
618 | - }else{ |
|
618 | + } else{ |
|
619 | 619 | $arg[] = (string)$entry; |
620 | 620 | } |
621 | - }elseif($entry->getName() == 'service'){ |
|
621 | + } elseif($entry->getName() == 'service'){ |
|
622 | 622 | $arg[] = $this->provideService($entry); |
623 | 623 | } |
624 | 624 | } |
625 | - }elseif($config->getName() == 'service'){ |
|
625 | + } elseif($config->getName() == 'service'){ |
|
626 | 626 | $arg = $this->provideService($config); |
627 | - }elseif($config->list){ |
|
627 | + } elseif($config->list){ |
|
628 | 628 | $arg = $this->buildArg($config->list); |
629 | - }elseif($config->service){ |
|
629 | + } elseif($config->service){ |
|
630 | 630 | $arg = $this->buildArg($config->service); |
631 | 631 | } |
632 | 632 | return $arg; |
@@ -694,7 +694,7 @@ discard block |
||
694 | 694 | $channel = $this->services[trim((string)$channelName)]; |
695 | 695 | if($channel instanceof \PEIP\INF\Channel\Channel){ |
696 | 696 | return $channel; |
697 | - }else{ |
|
697 | + } else{ |
|
698 | 698 | return NULL; |
699 | 699 | } |
700 | 700 | } |
@@ -718,10 +718,10 @@ discard block |
||
718 | 718 | $constructor = (string)$config["constructor"]; |
719 | 719 | if($constructor != ''){ |
720 | 720 | $service = call_user_func_array(array($cls, $constructor), $arguments); |
721 | - }else{ |
|
721 | + } else{ |
|
722 | 722 | $service = self::build($cls, $arguments); |
723 | 723 | } |
724 | - }catch(\Exception $e){ |
|
724 | + } catch(\Exception $e){ |
|
725 | 725 | throw new \RuntimeException('Could not create Service "'.$cls.'" -> '.$e->getMessage()); |
726 | 726 | } |
727 | 727 | } |
@@ -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, |
@@ -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 | } |