Completed
Push — v1.ns ( 6f2676...0f96a8 )
by Timo
03:42
created
src/Context/XMLContext.php 1 patch
Spacing   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -50,24 +50,24 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
246 246
         );
247 247
         $plugin = new BasePlugin();
248 248
         $this->addPlugin($plugin); 
249
-        foreach($builders as $nodeName => $method){
249
+        foreach ($builders as $nodeName => $method) {
250 250
             $this->registerNodeBuilder($nodeName, array($this, $method));   
251 251
         }       
252 252
     }
@@ -260,10 +260,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
359 359
      * @param $config 
360 360
      * @return object the initialized service instance
361 361
      */
362
-    public function createService($config){
362
+    public function createService($config) {
363 363
         return ServiceFactory::createService($config);      
364 364
     }
365 365
  
@@ -376,28 +376,28 @@  discard block
 block discarded – undo
376 376
      * @param object $config configuration to get the modification instructions from. 
377 377
      * @return object the modificated service
378 378
      */
379
-    protected function modifyService($service, $config){ 
379
+    protected function modifyService($service, $config) { 
380 380
         // set instance properties
381
-        if($config->property){          
382
-            foreach($config->property as $property){                          
381
+        if ($config->property) {          
382
+            foreach ($config->property as $property) {                          
383 383
                 $arg = $this->buildArg($property);
384
-                if($arg){
384
+                if ($arg) {
385 385
                     $setter = self::getSetter($property);               
386
-                    if($setter &&  self::hasPublicProperty($service, 'Method', $setter)){
386
+                    if ($setter && self::hasPublicProperty($service, 'Method', $setter)) {
387 387
                         $service->{$setter}($arg);  
388
-                    }elseif(in_array($property, self::hasPublicProperty($service, 'Property', $setter))){
388
+                    }elseif (in_array($property, self::hasPublicProperty($service, 'Property', $setter))) {
389 389
                         $service->$setter = $arg;
390 390
                     }                   
391 391
                 }
392 392
             }
393 393
         }   
394 394
         // call instance methods
395
-        if($config->action){            
396
-            foreach($config->action as $action){
395
+        if ($config->action) {            
396
+            foreach ($config->action as $action) {
397 397
                 $method = (string)$action['method'] != '' ? (string)$action['method'] : NULL;
398
-                if($method && self::hasPublicProperty($service, 'Method', $method)){
398
+                if ($method && self::hasPublicProperty($service, 'Method', $method)) {
399 399
                     $args = array(); 
400
-                    foreach($action->children() as $argument){
400
+                    foreach ($action->children() as $argument) {
401 401
                         $args[] = $this->buildArg($argument);
402 402
                     } 
403 403
                     call_user_func_array(array($service, (string)$action['method']), $args);
@@ -405,9 +405,9 @@  discard block
 block discarded – undo
405 405
             }
406 406
         }       
407 407
         // register instance listeners
408
-        if($service instanceof \PEIP\INF\Event\Connectable){
409
-            if($config->listener){
410
-                foreach($config->listener as $listenerConf){
408
+        if ($service instanceof \PEIP\INF\Event\Connectable) {
409
+            if ($config->listener) {
410
+                foreach ($config->listener as $listenerConf) {
411 411
                     $event = (string)$listenerConf['event'];
412 412
                     $listener = $this->provideService($listenerConf);  
413 413
                     $service->connect($event, $listener);   
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
      * @param mixed $id the id ofthe gateway 
427 427
      * @return object the gateway instance
428 428
      */
429
-    public function getGateway($id){ 
429
+    public function getGateway($id) { 
430 430
         return $this->getServiceProvider()->provideService($id); 
431 431
     }   
432 432
   
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
      * @param object $config configuration object for the pollable channel. 
439 439
      * @return \PEIP\INF\Channel\Channel the created pollable channel instance
440 440
      */
441
-    public function createChannel($config){
441
+    public function createChannel($config) {
442 442
         return $this->doCreateChannel($config, 'PollableChannel');        
443 443
     }
444 444
   
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
      * @param object $config configuration object for the subscribable channel. 
451 451
      * @return \PEIP\INF\Channel\Channel the created subscribable channel instance
452 452
      */
453
-    public function createSubscribableChannel($config){
453
+    public function createSubscribableChannel($config) {
454 454
         return $this->doCreateChannel($config, 'PublishSubscribeChannel');       
455 455
     }   
456 456
    
@@ -463,9 +463,9 @@  discard block
 block discarded – undo
463 463
      * @param $additionalArguments additional arguments for the channel constructor (without first arg = id)
464 464
      * @return \PEIP\INF\Channel\Channel the created channel instance
465 465
      */
466
-    public function doCreateChannel($config, $defaultChannelClass, array $additionalArguments = array()){
466
+    public function doCreateChannel($config, $defaultChannelClass, array $additionalArguments = array()) {
467 467
         $id = (string)$config['id'];
468
-        if($id != ''){ 
468
+        if ($id != '') { 
469 469
             array_unshift($additionalArguments, $id);
470 470
             $channel = $this->buildAndModify($config, $additionalArguments, $defaultChannelClass);
471 471
             $this->channelRegistry->register($channel);
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
      * @param string $defaultClass the class to use if none is set in config. 
483 483
      * @return object the gateway instance
484 484
      */
485
-    public function createGateway($config, $defaultClass = false){
485
+    public function createGateway($config, $defaultClass = false) {
486 486
         $args = array(
487 487
             $this->getRequestChannel($config), 
488 488
             $this->getReplyChannel($config)
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
      * @param string $defaultClass the class to use if none is set in config. 
507 507
      * @return object the router instance
508 508
      */
509
-    public function createRouter($config, $defaultClass = false){
509
+    public function createRouter($config, $defaultClass = false) {
510 510
         $resolver = $config['channel_resolver'] ? (string)$config['channel_resolver'] : $this->channelRegistry;
511 511
         return $this->buildAndModify($config, array(
512 512
             $resolver,
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
      * @param object $config configuration object for the splitter. 
524 524
      * @return object the splitter instance
525 525
      */    
526
-    public function createSplitter($config){
526
+    public function createSplitter($config) {
527 527
         return $this->createReplyMessageHandler($config);           
528 528
     }   
529 529
  
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
      * @param object $config configuration object for the transformer. 
537 537
      * @return object the transformer instance
538 538
      */    
539
-    public function createTransformer($config){
539
+    public function createTransformer($config) {
540 540
         return $this->createReplyMessageHandler($config);           
541 541
     } 
542 542
       
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
      * @param object $config configuration object for the aggregator. 
550 550
      * @return object the aggregator instance
551 551
      */  
552
-    public function createAggregator($config){
552
+    public function createAggregator($config) {
553 553
         return $this->createReplyMessageHandler($config);       
554 554
     }
555 555
   
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
      * @param object $config configuration object for the wiretap. 
563 563
      * @return object the wiretap instance
564 564
      */ 
565
-    public function createWiretap($config){
565
+    public function createWiretap($config) {
566 566
         return $this->createReplyMessageHandler($config, 'Wiretap');       
567 567
     }
568 568
   
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
      * @param string $defaultClass the class to use if none is set in config.
576 576
      * @return object the reply-message-handler instance
577 577
      */ 
578
-    public function createReplyMessageHandler($config, $defaultClass = false){
578
+    public function createReplyMessageHandler($config, $defaultClass = false) {
579 579
         return $this->buildAndModify($config, $this->getReplyHandlerArguments($config), $defaultClass); 
580 580
     }
581 581
     
@@ -588,12 +588,12 @@  discard block
 block discarded – undo
588 588
      * @param string $defaultClass the class to use if none is set in config. 
589 589
      * @return object the service-activator instance
590 590
      */
591
-    public function createServiceActivator($config, $defaultClass = false){
591
+    public function createServiceActivator($config, $defaultClass = false) {
592 592
         $method = (string)$config['method'];
593 593
         $service = $this->getService((string)$config['ref']);
594
-        if($method && $service){        
594
+        if ($method && $service) {        
595 595
             $args = $this->getReplyHandlerArguments($config);
596
-            array_unshift($args,array(
596
+            array_unshift($args, array(
597 597
                 $service,
598 598
                 $method             
599 599
             )); 
@@ -614,11 +614,11 @@  discard block
 block discarded – undo
614 614
      * @param object $config configuration object for the service. 
615 615
      * @return 
616 616
      */
617
-    protected function provideService($config){
617
+    protected function provideService($config) {
618 618
         $ref = trim((string)$config['ref']);
619
-        if($ref != ''){
619
+        if ($ref != '') {
620 620
             $service = $this->getService($ref); 
621
-        }else{
621
+        }else {
622 622
             $service = $this->createService($config);
623 623
         }
624 624
         return $service;
@@ -635,10 +635,10 @@  discard block
 block discarded – undo
635 635
      * @param object $config configuration object for the setter-method. 
636 636
      * @return string camel-cased 
637 637
      */    
638
-    protected static function getSetter($config){
639
-        if($config['setter']){
638
+    protected static function getSetter($config) {
639
+        if ($config['setter']) {
640 640
             $setter = (string)$config['setter'];
641
-        }elseif($config['name']){
641
+        }elseif ($config['name']) {
642 642
             $setter = 'set'.ucfirst((string)$config['name']);   
643 643
         }
644 644
         return $setter;     
@@ -651,29 +651,29 @@  discard block
 block discarded – undo
651 651
      * @param object $config configuration object to create argument from.  
652 652
      * @return mixed build argument 
653 653
      */
654
-    protected function buildArg($config){ 
655
-        if(trim((string)$config['value']) != ''){
654
+    protected function buildArg($config) { 
655
+        if (trim((string)$config['value']) != '') {
656 656
             $arg = (string)$config['value'];
657
-        }elseif($config->getName() == 'value'){
657
+        }elseif ($config->getName() == 'value') {
658 658
             $arg = (string)$config;
659
-        }elseif($config->getName() == 'list'){
659
+        }elseif ($config->getName() == 'list') {
660 660
             $arg = array();
661
-            foreach($config->children() as $entry){ 
662
-                if($entry->getName() == 'value'){
663
-                    if($entry['key']){
661
+            foreach ($config->children() as $entry) { 
662
+                if ($entry->getName() == 'value') {
663
+                    if ($entry['key']) {
664 664
                         $arg[(string)$entry['key']] = (string)$entry;   
665
-                    }else{
665
+                    }else {
666 666
                         $arg[] = (string)$entry;
667 667
                     }
668
-                }elseif($entry->getName() == 'service'){
668
+                }elseif ($entry->getName() == 'service') {
669 669
                     $arg[] = $this->provideService($entry);
670 670
                 }
671 671
             }
672
-        }elseif($config->getName() == 'service'){
672
+        }elseif ($config->getName() == 'service') {
673 673
             $arg = $this->provideService($config);
674
-        }elseif($config->list){
674
+        }elseif ($config->list) {
675 675
             $arg = $this->buildArg($config->list);
676
-        }elseif($config->service){
676
+        }elseif ($config->service) {
677 677
             $arg = $this->buildArg($config->service);
678 678
         } 
679 679
         return $arg; 
@@ -687,12 +687,12 @@  discard block
 block discarded – undo
687 687
      * @param object $config configuration object to create arguments from.  
688 688
      * @return mixed build arguments 
689 689
      */
690
-    protected function getReplyHandlerArguments($config){
690
+    protected function getReplyHandlerArguments($config) {
691 691
         $args = array(
692 692
             $this->doGetChannel('input', $config),
693 693
             $this->doGetChannel('output', $config)
694 694
         );
695
-        if($args[0] == NULL){
695
+        if ($args[0] == NULL) {
696 696
             throw new \RuntimeException('Could not receive input channel.');
697 697
         }
698 698
         return $args;
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
      * @param object $config configuration object to return request-channel from. 
708 708
      * @return \PEIP\INF\Channel\Channel request-channel
709 709
      */
710
-    protected function getRequestChannel($config){
710
+    protected function getRequestChannel($config) {
711 711
         return $this->doGetChannel('request', $config); 
712 712
     }
713 713
     
@@ -720,7 +720,7 @@  discard block
 block discarded – undo
720 720
      * @param object $config configuration object to return reply-channel from. 
721 721
      * @return \PEIP\INF\Channel\Channel reply-channel
722 722
      */
723
-    protected function getReplyChannel($config){
723
+    protected function getReplyChannel($config) {
724 724
         return $this->doGetChannel('reply', $config);   
725 725
     }
726 726
     
@@ -733,7 +733,7 @@  discard block
 block discarded – undo
733 733
      * @param object $config configuration object to return channel from. 
734 734
      * @return \PEIP\INF\Channel\Channel reply-channel
735 735
      */
736
-    public function doGetChannel($type, $config){
736
+    public function doGetChannel($type, $config) {
737 737
         $channelName = $config[$type."_channel"] 
738 738
             ? $config[$type."_channel"] 
739 739
             : $config["default_".$type."_channel"];
@@ -753,7 +753,7 @@  discard block
 block discarded – undo
753 753
      * @param string $defaultClass class to create instance for if none is set in config 
754 754
      * @return object build and modified srvice instance
755 755
      */
756
-    public function buildAndModify($config, $arguments, $defaultClass = false){   
756
+    public function buildAndModify($config, $arguments, $defaultClass = false) {   
757 757
         return ServiceFactory::buildAndModify($config, $arguments, $defaultClass);
758 758
     }
759 759
 
@@ -767,21 +767,21 @@  discard block
 block discarded – undo
767 767
      * @param string $defaultClass class to create instance for if none is set in config 
768 768
      * @return object build and modified srvice instance
769 769
      */    
770
-    protected static function doBuild($config, $arguments, $defaultClass = false){
770
+    protected static function doBuild($config, $arguments, $defaultClass = false) {
771 771
         $cls = $config["class"] ? trim((string)$config["class"]) : (string)$defaultClass;
772
-        if($cls != ''){
772
+        if ($cls != '') {
773 773
             try {
774 774
                 $constructor = (string)$config["constructor"];
775
-        if($constructor != ''){
775
+        if ($constructor != '') {
776 776
             $service = call_user_func_array(array($cls, $constructor), $arguments); 
777
-        }else{
777
+        }else {
778 778
             $service = self::build($cls, $arguments); 
779 779
         }        
780
-            }catch(\Exception $e){
780
+            } catch (\Exception $e) {
781 781
                 throw new \RuntimeException('Could not create Service "'.$cls.'" -> '.$e->getMessage());
782 782
             }           
783 783
         }
784
-        if(is_object($service)){
784
+        if (is_object($service)) {
785 785
             return $service;
786 786
         }       
787 787
         throw new \RuntimeException('Could not create Service "'.$cls.'". Class does not exist.');           
@@ -797,13 +797,13 @@  discard block
 block discarded – undo
797 797
      * @param array $arguments arguments for the constructor 
798 798
      * @return object build and modified srvice instance
799 799
      */     
800
-    protected static function build($className, $arguments){
800
+    protected static function build($className, $arguments) {
801 801
         return GenericBuilder::getInstance($className)->build($arguments);
802 802
     }
803 803
 
804
-    protected static function hasPublicProperty($service, $type, $name){
804
+    protected static function hasPublicProperty($service, $type, $name) {
805 805
         $reflection = GenericBuilder::getInstance(get_class($service))->getReflectionClass();
806
-        if($reflection->{'has'.$type}($name) && $reflection->{'get'.$type}($name)->isPublic()){
806
+        if ($reflection->{'has'.$type}($name) && $reflection->{'get'.$type}($name)->isPublic()) {
807 807
                 return true;
808 808
         }
809 809
         return false;
Please login to merge, or discard this patch.
src/Context/XMLContextReader.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,21 +19,21 @@
 block discarded – undo
19 19
     protected $config;
20 20
 
21 21
 
22
-    public function __construct($config){ 
22
+    public function __construct($config) { 
23 23
         $this->config = ($config);       
24 24
     }
25 25
 
26
-    public function read(){      
26
+    public function read() {      
27 27
         $iterator = new \SimpleXMLIterator($this->config);
28 28
         $iterator->rewind();
29
-        while($iterator->valid()){
29
+        while ($iterator->valid()) {
30 30
             
31 31
             $arrayNode = XMLArrayTranslator::translate($iterator->current()->asXML()); 
32 32
             $this->doFireEvent('read_node', array('NODE'=>$arrayNode));            
33 33
             $iterator->next();
34 34
         }
35 35
         
36
-        foreach($iterator as $xmlNode){  
36
+        foreach ($iterator as $xmlNode) {  
37 37
 
38 38
         }
39 39
         $this->config = array();
Please login to merge, or discard this patch.
src/Message/GenericMessage.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
      * @param mixed $content The content/payload of the message 
42 42
      * @param array|ArrayAccess $headers headers as key/value pairs
43 43
      */
44
-    public function __construct($content, $headers = array()){
44
+    public function __construct($content, $headers = array()) {
45 45
         $this->doSetContent($content);
46 46
         $this->doSetHeaders($headers);          
47 47
     }
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
      * @access public
54 54
      * @return
55 55
      */
56
-    public function getContent(){
56
+    public function getContent() {
57 57
         return $this->content;
58 58
     }
59 59
 
@@ -63,13 +63,13 @@  discard block
 block discarded – undo
63 63
      * @access protected
64 64
      * @param mixed $content The content/payload of the message 
65 65
      */
66
-    protected function doSetContent($content){
66
+    protected function doSetContent($content) {
67 67
         $this->content = Test::castType($content, self::CONTENT_CAST_TYPE);
68 68
     }
69 69
 
70
-    protected function doSetHeaders($headers){
70
+    protected function doSetHeaders($headers) {
71 71
         $headers = Test::ensureArrayAccess($headers);
72
-        if(is_array($headers)){
72
+        if (is_array($headers)) {
73 73
             $headers = new \ArrayObject($headers);
74 74
         }
75 75
         $this->headers = $headers;
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
      * @access public
82 82
      * @return ArrayAccess ArrayAccess object of headers
83 83
      */
84
-    public function getHeaders(){
85
-        return (array) $this->headers;
84
+    public function getHeaders() {
85
+        return (array)$this->headers;
86 86
     }
87 87
   
88 88
     /**
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
      * @param string $name the name of the header  
93 93
      * @return mixed the value of the header
94 94
      */
95
-    public function getHeader($name){
95
+    public function getHeader($name) {
96 96
         $name = (string)$name;
97 97
         return isset($this->headers[$name]) ? $this->headers[$name] : NULL;
98 98
     }
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
      * @param string $name the name of the header
106 106
      * @return boolean wether the header has been successfully  set
107 107
      */
108
-    public function addHeader($name, $value){
109
-        if(!$this->hasHeader($name)){
108
+    public function addHeader($name, $value) {
109
+        if (!$this->hasHeader($name)) {
110 110
             $this->headers[$name] = $value;
111 111
             return true;
112 112
         }
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
      * @param string $name the name of the header
121 121
      * @return boolean wether the header is set
122 122
      */
123
-    public function hasHeader($name){
123
+    public function hasHeader($name) {
124 124
         return isset($this->headers[$name]);
125 125
     }
126 126
 
@@ -130,16 +130,16 @@  discard block
 block discarded – undo
130 130
      * @access public
131 131
      * @return string  content/payload of the message
132 132
      */
133
-    public function __toString(){
133
+    public function __toString() {
134 134
         $res = false;
135 135
         try {
136 136
             $res = (string)$this->getContent();
137 137
         }
138
-        catch(\Exception $e){           
138
+        catch (\Exception $e) {           
139 139
             try {
140 140
                 $res = get_class($this->getContent());
141 141
             }
142
-            catch(\Exception $e){
142
+            catch (\Exception $e) {
143 143
                 return "";
144 144
             }
145 145
         }     
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
      * @param array $arguments argumends for the constructor
158 158
      * @return GenericMessage new class instance
159 159
      */    
160
-    public static function build(array $arguments = array()){
160
+    public static function build(array $arguments = array()) {
161 161
         return GenericBuilder::getInstance(__CLASS__)->build($arguments);
162 162
     }     
163 163
 } 
164 164
\ No newline at end of file
Please login to merge, or discard this patch.
src/Message/TextMessage.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
      * @param $title 
35 35
      * @return 
36 36
      */
37
-    public function __construct($content, $title){
37
+    public function __construct($content, $title) {
38 38
         $this->setContent((string)$content);
39 39
     }
40 40
 
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
      * @param $title 
45 45
      * @return 
46 46
      */
47
-    public function setTitle($title){
47
+    public function setTitle($title) {
48 48
         $this->title = (string)$title;
49 49
     }
50 50
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
      * @access public
54 54
      * @return 
55 55
      */
56
-    public function getTitle(){
56
+    public function getTitle() {
57 57
         return $this->title;
58 58
     }
59 59
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
      * @param string $name the name of the header
68 68
      * @return boolean wether the header is set
69 69
      */
70
-    public static function build(array $arguments = array()){
70
+    public static function build(array $arguments = array()) {
71 71
         return GenericBuilder::getInstance('\PEIP\Message\StringMessage')->build($arguments);
72 72
     }
73 73
 
Please login to merge, or discard this patch.
src/Message/MessageBuilder.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
      * @access public
40 40
      * @param string $messageClass the message-class to build instances for 
41 41
      */
42
-    public function __construct($messageClass = '\PEIP\Message\GenericMessage'){
42
+    public function __construct($messageClass = '\PEIP\Message\GenericMessage') {
43 43
         $this->messageClass = $messageClass;
44 44
         $this->factory = DedicatedFactory::getfromCallable(array($messageClass, 'build'));    
45 45
     }
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
      * @param array $headers the headers to set
52 52
      * @return MessageBuilder $this
53 53
      */
54
-    public function copyHeaders(array $headers){
54
+    public function copyHeaders(array $headers) {
55 55
         $this->headers = array_merge($this->headers, $headers);
56 56
         return $this;       
57 57
     }
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
      * @param array $headers the headers to set
64 64
      * @return MessageBuilder $this
65 65
      */
66
-    public function copyHeadersIfAbsent(array $headers){
66
+    public function copyHeadersIfAbsent(array $headers) {
67 67
         $this->headers = array_merge($headers, $this->headers);
68 68
         return $this;   
69 69
     }
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
      * @param string $headerName the name of the header
76 76
      * @return MessageBuilder $this
77 77
      */
78
-    public function removeHeader($headerName){
78
+    public function removeHeader($headerName) {
79 79
         unset($this->headers[$headerName]);
80 80
         return $this;
81 81
     }
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
      * @param mixed $headerValue the value for the header
89 89
      * @return MessageBuilder $this 
90 90
      */
91
-    public function setHeader($headerName, $headerValue){
91
+    public function setHeader($headerName, $headerValue) {
92 92
         $this->headers[$headerName] = $headerValue;
93 93
         return $this;   
94 94
     }
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
      * @param array $headers the headers to set
101 101
      * @return MessageBuilder $this 
102 102
      */
103
-    public function setHeaders(array $headers){
103
+    public function setHeaders(array $headers) {
104 104
         $this->headers = $headers;
105 105
         return $this;   
106 106
     }
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
      * @access public
112 112
      * @return array the headers for the message to build 
113 113
      */
114
-    public function getHeaders(){
114
+    public function getHeaders() {
115 115
         return $this->headers;
116 116
     }  
117 117
         
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
      * @param $arguments 
123 123
      * @return 
124 124
      */
125
-    public function build(array $headers = array()){
125
+    public function build(array $headers = array()) {
126 126
         $this->copyHeaders($headers);
127 127
         return GenericBuilder::getInstance($this->messageClass)
128 128
             ->build(array($this->payload, new \ArrayObject($this->headers)));        
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
      * @param mixed $payload payload for the message to build 
136 136
      * @return MessageBuilder $this 
137 137
      */
138
-    public function setContent($payload){
138
+    public function setContent($payload) {
139 139
         $this->payload = $payload;
140 140
         return $this;
141 141
     }
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
      * @param string $messageClass the message class to build from the builder 
149 149
      * @return MessageBuilder new instance of MessageBuilder 
150 150
      */    
151
-    public static function getInstance($messageClass = '\PEIP\Message\GenericMessage'){
151
+    public static function getInstance($messageClass = '\PEIP\Message\GenericMessage') {
152 152
         return new  MessageBuilder($messageClass);
153 153
     }
154 154
   
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
      * @param \PEIP\INF\Message\Message $message the message to get class to build from the builder 
161 161
      * @return MessageBuilder new instance of MessageBuilder 
162 162
      */      
163
-    public static function getInstanceFromMessage(\PEIP\INF\Message\Message $message){
163
+    public static function getInstanceFromMessage(\PEIP\INF\Message\Message $message) {
164 164
         return new MessageBuilder(get_class($message));
165 165
     }
166 166
    
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
      * @access public
171 171
      * @param string $messageClass the message-class to build new instances for
172 172
      */
173
-    public function setMessageClass($messageClass){
173
+    public function setMessageClass($messageClass) {
174 174
         $this->messageClass = $messageClass;
175 175
     }
176 176
  
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
      * @access public
181 181
      * @return string the message-class to build new instances for
182 182
      */
183
-    public function getMessageClass(){
183
+    public function getMessageClass() {
184 184
         return $this->messageClass;
185 185
     }         
186 186
 }
187 187
\ No newline at end of file
Please login to merge, or discard this patch.
src/Message/CommandMessage.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
      * @param $headers 
38 38
      * @return 
39 39
      */
40
-    public function __construct($content, ArrayAccess $headers = NULL){
41
-        if(!($content instanceof \PEIP\INF\Command\Command) && !is_callable($content)){
40
+    public function __construct($content, ArrayAccess $headers = NULL) {
41
+        if (!($content instanceof \PEIP\INF\Command\Command) && !is_callable($content)) {
42 42
             throw new \BadArgumentException('Argument 1 for CommandMessage::__construct must be callable or implment \PEIP\INF\Command\Command');
43 43
         }
44 44
         
@@ -51,10 +51,10 @@  discard block
 block discarded – undo
51 51
      * @access public
52 52
      * @return 
53 53
      */
54
-    public function execute(){
55
-        if(is_callable($this->getContent())){
54
+    public function execute() {
55
+        if (is_callable($this->getContent())) {
56 56
             return call_user_func($this->getContent());
57
-        }else{
57
+        }else {
58 58
             return $this->getContent()->execute();
59 59
         }
60 60
     }
Please login to merge, or discard this patch.
src/Message/CallableMessageHandler.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
      * @param $callable 
36 36
      * @return 
37 37
      */
38
-    public function __construct($callable){
38
+    public function __construct($callable) {
39 39
         $this->callable = $callable;    
40 40
         $this->examineCallabe();
41 41
     }
@@ -45,22 +45,22 @@  discard block
 block discarded – undo
45 45
      * @access protected
46 46
      * @return 
47 47
      */
48
-    protected function examineCallabe(){
49
-        if(is_callable($this->callable)){        
50
-            if(is_array($this->callable)){
51
-                list($class, $method) =  $this->callable;
48
+    protected function examineCallabe() {
49
+        if (is_callable($this->callable)) {        
50
+            if (is_array($this->callable)) {
51
+                list($class, $method) = $this->callable;
52 52
                 $static = !is_object($class);
53 53
                 $class = is_object($class) ? get_class($class) : (string)$class;
54 54
                 $reflectionClass = new \ReflectionClass($class);
55 55
                 $reflectionFunc = $reflectionClass->getMethod($method);
56
-                if($static && !$reflectionFunc->isStatic()){
56
+                if ($static && !$reflectionFunc->isStatic()) {
57 57
                     throw new \InvalidArgumentException('Argument 1 passed to CallableMessageHandler::__construct is not an Callable: Method "'.$method.'" of class '.$class.' is not static.');                  
58 58
                 }
59
-            }else{
59
+            }else {
60 60
                 $reflectionFunc = new \ReflectionFunction($this->callable);  
61 61
             }
62 62
             $this->requiredParameters = $reflectionFunc->getNumberOfRequiredParameters();
63
-        }else{
63
+        }else {
64 64
             throw new \InvalidArgumentException('Argument 1 passed to CallableMessageHandler::__construct is not a Callable');
65 65
         }   
66 66
     }   
@@ -73,14 +73,14 @@  discard block
 block discarded – undo
73 73
      * @param $sent 
74 74
      * @return 
75 75
      */
76
-    public function handle($message, $channel = false, $sent = false){
77
-        if(!is_object($message)){
76
+    public function handle($message, $channel = false, $sent = false) {
77
+        if (!is_object($message)) {
78 78
             throw new \InvalidArgumentException('Argument 1 passed to CallableMessageHandler::handle is not a Object');       
79 79
         }   
80 80
         try {
81 81
             return call_user_func_array($this->callable, array($message, $channel, $sent));
82 82
         }
83
-        catch(\Exception $e){
83
+        catch (\Exception $e) {
84 84
             throw new \RuntimeException('Unable to call Callable: '.$e->getMessage());
85 85
         }   
86 86
     }   
Please login to merge, or discard this patch.
src/Message/ErrorMessage.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@
 block discarded – undo
36 36
      * @param $headers 
37 37
      * @return 
38 38
      */
39
-    public function __construct(\Exception $payload, array $headers = array()){
39
+    public function __construct(\Exception $payload, array $headers = array()) {
40 40
         $this->payload = $payload;
41 41
         $this->headers = $headers;
42 42
     }
Please login to merge, or discard this patch.
src/Message/StringMessage.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -27,11 +27,11 @@  discard block
 block discarded – undo
27 27
 
28 28
     const CONTENT_CAST_TYPE = 'string';
29 29
 
30
-    public function __toString(){
30
+    public function __toString() {
31 31
         return (string)$this->getContent();
32 32
     }
33 33
 
34
-    public function getContent(){
34
+    public function getContent() {
35 35
         return (string)parent::getContent();
36 36
     }
37 37
 
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
      * @param string $name the name of the header
46 46
      * @return boolean wether the header is set
47 47
      */     
48
-    public static function build(array $arguments = array()){
48
+    public static function build(array $arguments = array()) {
49 49
         return GenericBuilder::getInstance(__CLASS__)->build($arguments);
50 50
     }
51 51
 }
52 52
\ No newline at end of file
Please login to merge, or discard this patch.