@@ -342,7 +342,7 @@ |
||
342 | 342 | * |
343 | 343 | * @access protected |
344 | 344 | * @param object $config |
345 | - * @return object the initialized service instance |
|
345 | + * @return \PEIP\INF\Context\ContextPlugin|null the initialized service instance |
|
346 | 346 | */ |
347 | 347 | protected function initService($config) { |
348 | 348 | $id = trim((string)$config['id']); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @param string $nodeName the name of the node |
127 | 127 | * @param callable $callable a callable which creates instances for node-name |
128 | 128 | */ |
129 | - public function registerNodeBuilder($nodeName, $callable){ |
|
129 | + public function registerNodeBuilder($nodeName, $callable) { |
|
130 | 130 | return $this->getServiceProvider()->registerNodeBuilder($nodeName, $callable); |
131 | 131 | } |
132 | 132 | |
@@ -797,7 +797,7 @@ discard block |
||
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 | |
@@ -805,9 +805,9 @@ discard block |
||
805 | 805 | * @param string $type |
806 | 806 | * @param string $name |
807 | 807 | */ |
808 | - protected static function hasPublicProperty($service, $type, $name){ |
|
808 | + protected static function hasPublicProperty($service, $type, $name) { |
|
809 | 809 | $reflection = GenericBuilder::getInstance(get_class($service))->getReflectionClass(); |
810 | - if($reflection->{'has'.$type}($name) && $reflection->{'get'.$type}($name)->isPublic()){ |
|
810 | + if ($reflection->{'has'.$type}($name) && $reflection->{'get'.$type}($name)->isPublic()) { |
|
811 | 811 | return true; |
812 | 812 | } |
813 | 813 | return false; |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | public static function createFromFile($file) { |
95 | 95 | if (file_exists($file)) { |
96 | 96 | return self::createFromString(file_get_contents($file)); |
97 | - }else { |
|
97 | + } else { |
|
98 | 98 | throw new \RuntimeException('Cannot open file "'.$file.'".'); |
99 | 99 | } |
100 | 100 | } |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | $setter = self::getSetter($property); |
385 | 385 | if ($setter && self::hasPublicProperty($service, 'Method', $setter)) { |
386 | 386 | $service->{$setter}($arg); |
387 | - }elseif (in_array($property, self::hasPublicProperty($service, 'Property', $setter))) { |
|
387 | + } elseif (in_array($property, self::hasPublicProperty($service, 'Property', $setter))) { |
|
388 | 388 | $service->$setter = $arg; |
389 | 389 | } |
390 | 390 | } |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | $ref = trim((string)$config['ref']); |
618 | 618 | if ($ref != '') { |
619 | 619 | $service = $this->getService($ref); |
620 | - }else { |
|
620 | + } else { |
|
621 | 621 | $service = $this->createService($config); |
622 | 622 | } |
623 | 623 | return $service; |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | protected static function getSetter($config) { |
638 | 638 | if ($config['setter']) { |
639 | 639 | $setter = (string)$config['setter']; |
640 | - }elseif ($config['name']) { |
|
640 | + } elseif ($config['name']) { |
|
641 | 641 | $setter = 'set'.ucfirst((string)$config['name']); |
642 | 642 | } |
643 | 643 | return $setter; |
@@ -653,26 +653,26 @@ discard block |
||
653 | 653 | protected function buildArg($config) { |
654 | 654 | if (trim((string)$config['value']) != '') { |
655 | 655 | $arg = (string)$config['value']; |
656 | - }elseif ($config->getName() == 'value') { |
|
656 | + } elseif ($config->getName() == 'value') { |
|
657 | 657 | $arg = (string)$config; |
658 | - }elseif ($config->getName() == 'list') { |
|
658 | + } elseif ($config->getName() == 'list') { |
|
659 | 659 | $arg = array(); |
660 | 660 | foreach ($config->children() as $entry) { |
661 | 661 | if ($entry->getName() == 'value') { |
662 | 662 | if ($entry['key']) { |
663 | 663 | $arg[(string)$entry['key']] = (string)$entry; |
664 | - }else { |
|
664 | + } else { |
|
665 | 665 | $arg[] = (string)$entry; |
666 | 666 | } |
667 | - }elseif ($entry->getName() == 'service') { |
|
667 | + } elseif ($entry->getName() == 'service') { |
|
668 | 668 | $arg[] = $this->provideService($entry); |
669 | 669 | } |
670 | 670 | } |
671 | - }elseif ($config->getName() == 'service') { |
|
671 | + } elseif ($config->getName() == 'service') { |
|
672 | 672 | $arg = $this->provideService($config); |
673 | - }elseif ($config->list) { |
|
673 | + } elseif ($config->list) { |
|
674 | 674 | $arg = $this->buildArg($config->list); |
675 | - }elseif ($config->service) { |
|
675 | + } elseif ($config->service) { |
|
676 | 676 | $arg = $this->buildArg($config->service); |
677 | 677 | } |
678 | 678 | return $arg; |
@@ -774,7 +774,7 @@ discard block |
||
774 | 774 | $constructor = (string)$config["constructor"]; |
775 | 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 | 780 | } catch (\Exception $e) { |
@@ -87,7 +87,7 @@ |
||
87 | 87 | * @param array $headers headers of the event-object as key/value pairs |
88 | 88 | * @param string $eventClass event-class to create instances from |
89 | 89 | * @return |
90 | - * @see EventBuilder |
|
90 | + boolean|null @see EventBuilder |
|
91 | 91 | */ |
92 | 92 | public function buildAndNotify($name, $object, array $headers = array(), $eventClass = false, $type = false){ |
93 | 93 | if(!$this->hasListeners($name, ($object))){ |
@@ -26,9 +26,9 @@ discard block |
||
26 | 26 | * @param Callable|PEIP\INF\Handler\Handler $listener event-handler |
27 | 27 | * @return boolean |
28 | 28 | */ |
29 | - public function connect($name, $object, $listener){ |
|
29 | + public function connect($name, $object, $listener) { |
|
30 | 30 | $class = is_object($object) ? get_class($object) : (string)$object; |
31 | - foreach(Reflection::getImplementedClassesAndInterfaces($object) as $cls){ |
|
31 | + foreach (Reflection::getImplementedClassesAndInterfaces($object) as $cls) { |
|
32 | 32 | $reflection = \PEIP\Util\ReflectionPool::getInstance($class); |
33 | 33 | parent::connect($name, $reflection, $listener); |
34 | 34 | } |
@@ -36,13 +36,13 @@ discard block |
||
36 | 36 | return true; |
37 | 37 | } |
38 | 38 | |
39 | - public function disconnect($name, $object, $listener){ |
|
39 | + public function disconnect($name, $object, $listener) { |
|
40 | 40 | $class = is_object($object) ? get_class($object) : (string)$object; |
41 | 41 | $res = true; |
42 | - foreach(Reflection::getImplementedClassesAndInterfaces($object) as $cls){ |
|
42 | + foreach (Reflection::getImplementedClassesAndInterfaces($object) as $cls) { |
|
43 | 43 | $reflection = \PEIP\Util\ReflectionPool::getInstance($class); |
44 | 44 | $r = parent::disconnect($name, $reflection, $listener); |
45 | - if(!$r){ |
|
45 | + if (!$r) { |
|
46 | 46 | $res = false; |
47 | 47 | } |
48 | 48 | } |
@@ -69,10 +69,10 @@ discard block |
||
69 | 69 | ), |
70 | 70 | $object |
71 | 71 | ); |
72 | - }else{ |
|
72 | + }else { |
|
73 | 73 | throw new \InvalidArgumentException('instance of \PEIP\INF\Event\Event must contain subject'); |
74 | 74 | } |
75 | - }else{ |
|
75 | + }else { |
|
76 | 76 | throw new \InvalidArgumentException('object must be instance of \PEIP\INF\Event\Event'); |
77 | 77 | } |
78 | 78 | } //put your code here |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | * @return |
90 | 90 | * @see EventBuilder |
91 | 91 | */ |
92 | - public function buildAndNotify($name, $object, array $headers = array(), $eventClass = false, $type = false){ |
|
93 | - if(!$this->hasListeners($name, ($object))){ |
|
92 | + public function buildAndNotify($name, $object, array $headers = array(), $eventClass = false, $type = false) { |
|
93 | + if (!$this->hasListeners($name, ($object))) { |
|
94 | 94 | return false; |
95 | 95 | } |
96 | 96 |
@@ -9,7 +9,7 @@ |
||
9 | 9 | // simple service class |
10 | 10 | class HelloService { |
11 | 11 | |
12 | - public function greet($name){ |
|
12 | + public function greet($name) { |
|
13 | 13 | return 'Hello '.$name; |
14 | 14 | } |
15 | 15 |
@@ -6,7 +6,7 @@ |
||
6 | 6 | $deliveredDrinks, |
7 | 7 | $orderNumber; |
8 | 8 | |
9 | - public function __construct(array $deliveredDrinks){ |
|
9 | + public function __construct(array $deliveredDrinks) { |
|
10 | 10 | $this->deliveredDrinks = $deliveredDrinks; |
11 | 11 | $this->orderNumber = $deliveredDrinks[0]->getOrderNumber(); |
12 | 12 | } |
@@ -8,21 +8,21 @@ |
||
8 | 8 | $type, |
9 | 9 | $iced; |
10 | 10 | |
11 | - public function __construct($orderNumber, $type, $iced){ |
|
11 | + public function __construct($orderNumber, $type, $iced) { |
|
12 | 12 | $this->orderNumber = $orderNumber; |
13 | 13 | $this->type = $type; |
14 | 14 | $this->iced = $iced; |
15 | 15 | } |
16 | 16 | |
17 | - public function getType(){ |
|
17 | + public function getType() { |
|
18 | 18 | return $this->type; |
19 | 19 | } |
20 | 20 | |
21 | - public function getIced(){ |
|
21 | + public function getIced() { |
|
22 | 22 | return $this->iced; |
23 | 23 | } |
24 | 24 | |
25 | - public function getOrderNumber(){ |
|
25 | + public function getOrderNumber() { |
|
26 | 26 | return $this->orderNumber; |
27 | 27 | } |
28 | 28 |
@@ -7,16 +7,16 @@ discard block |
||
7 | 7 | $orderNumber; |
8 | 8 | protected static $orderCount = 0; |
9 | 9 | |
10 | - public function __construct(){ |
|
10 | + public function __construct() { |
|
11 | 11 | self::$orderCount++; |
12 | 12 | $this->orderNumber = self::$orderCount; |
13 | 13 | } |
14 | 14 | |
15 | - public function getOrderNumber(){ |
|
15 | + public function getOrderNumber() { |
|
16 | 16 | return $this->orderNumber; |
17 | 17 | } |
18 | 18 | |
19 | - public function addItem($type, $number, $iced = false){ |
|
19 | + public function addItem($type, $number, $iced = false) { |
|
20 | 20 | $this->items[] = |
21 | 21 | array( |
22 | 22 | 'type' => $type, |
@@ -25,13 +25,13 @@ discard block |
||
25 | 25 | ); |
26 | 26 | } |
27 | 27 | |
28 | - public function getItems(){ |
|
28 | + public function getItems() { |
|
29 | 29 | return $this->items; |
30 | 30 | } |
31 | 31 | |
32 | - public function getTotalCount(){ |
|
32 | + public function getTotalCount() { |
|
33 | 33 | $x = 0; |
34 | - foreach($this->items as $item){ |
|
34 | + foreach ($this->items as $item) { |
|
35 | 35 | $x += (int)$item['number']; |
36 | 36 | } |
37 | 37 | return $x; |
@@ -3,7 +3,7 @@ |
||
3 | 3 | class Cafe |
4 | 4 | extends \PEIP\Gateway\SimpleMessagingGateway { |
5 | 5 | |
6 | - public function placeOrder(Order $order){ |
|
6 | + public function placeOrder(Order $order) { |
|
7 | 7 | return $this->sendAndReceive($order); |
8 | 8 | } |
9 | 9 |
@@ -5,18 +5,18 @@ |
||
5 | 5 | |
6 | 6 | protected $orders; |
7 | 7 | |
8 | - public function prepareDelivery(array $drinks){ |
|
8 | + public function prepareDelivery(array $drinks) { |
|
9 | 9 | echo PEIP_LINE_SEPARATOR.'Waiter: prepareDelivery: #'.$drinks[0]->getOrderNumber(); |
10 | 10 | return new Delivery($drinks); |
11 | 11 | } |
12 | 12 | |
13 | 13 | |
14 | - public function receiveOrder(Order $order){ |
|
14 | + public function receiveOrder(Order $order) { |
|
15 | 15 | echo PEIP_LINE_SEPARATOR.'Waiter: receiveOrder'; |
16 | 16 | $this->orders[$order->getOrderNumber()] = $order; |
17 | 17 | } |
18 | 18 | |
19 | - public function getOrder($nr){ |
|
19 | + public function getOrder($nr) { |
|
20 | 20 | return $this->orders[$nr]; |
21 | 21 | } |
22 | 22 |
@@ -30,16 +30,16 @@ |
||
30 | 30 | return $this->prepareDrink($orderItem['order'], $orderItem['type'], true); |
31 | 31 | } |
32 | 32 | |
33 | - protected function prepareDrink($orderNumber, $type, $iced){ |
|
33 | + protected function prepareDrink($orderNumber, $type, $iced) { |
|
34 | 34 | $drink = new Drink($orderNumber, $type, $iced); |
35 | 35 | return $drink; |
36 | 36 | } |
37 | 37 | |
38 | - protected function printAction($cold, $orderNr){ |
|
39 | - if($cold){ |
|
38 | + protected function printAction($cold, $orderNr) { |
|
39 | + if ($cold) { |
|
40 | 40 | $type = 'cold'; |
41 | 41 | $count = $this->coldDrinkCounter; |
42 | - }else{ |
|
42 | + }else { |
|
43 | 43 | $type = 'hot'; |
44 | 44 | $count = $this->hotDrinkCounter; |
45 | 45 | } |