Completed
Push — v1.ns ( ff674e...64f725 )
by Timo
03:35
created
examples/Cafe/example.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
  */
45 45
 
46 46
 
47
-if($cafe){
47
+if ($cafe) {
48 48
 
49 49
 	for ($i = 1; $i <= 10; $i++) {
50 50
        	// create and place orders
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
                 var_dump($drinks);
58 58
     	}	
59 59
 
60
-}else{
60
+}else {
61 61
 	throw new RuntimeException('Could not get CafeGateway');
62 62
 }
63 63
 
Please login to merge, or discard this patch.
examples/Cafe/misc/bootstrap.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2,11 +2,11 @@
 block discarded – undo
2 2
 
3 3
 require_once(dirname(__FILE__).'/../../../misc/bootstrap.php');
4 4
 
5
-foreach (glob(realpath(dirname(__FILE__)."/../lib/model/")."/*.php") as $filename){
5
+foreach (glob(realpath(dirname(__FILE__)."/../lib/model/")."/*.php") as $filename) {
6 6
     require_once $filename;
7 7
 }
8 8
 
9
-foreach (glob(realpath(dirname(__FILE__)."/../lib/messaging/")."/*.php") as $filename){
9
+foreach (glob(realpath(dirname(__FILE__)."/../lib/messaging/")."/*.php") as $filename) {
10 10
     require_once $filename;
11 11
 }
12 12
 
Please login to merge, or discard this patch.
examples/Cafe/lib/messaging/CafeGateway.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,12 +4,12 @@
 block discarded – undo
4 4
 
5 5
 class CafeGateway extends SimpleMessagingGateway {
6 6
 
7
-	public function placeOrder(Order $order){
7
+	public function placeOrder(Order $order) {
8 8
 		echo "\nCafe: place order #".$order->getOrderNumber();
9 9
 		$this->send($order);
10 10
 	}
11 11
 	
12
-	public function receiveDelivery(){
12
+	public function receiveDelivery() {
13 13
 		return $this->receive();
14 14
 	}
15 15
 
Please login to merge, or discard this patch.
examples/Cafe/lib/messaging/DrinkAggregator.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -9,30 +9,30 @@
 block discarded – undo
9 9
 	protected $orders = array();
10 10
 	protected $preparedDrinks = array();
11 11
 	
12
-	public function __construct(Channel $inputChannel, Channel $outputChannel = NULL){
12
+	public function __construct(Channel $inputChannel, Channel $outputChannel = NULL) {
13 13
 		$this->setInputChannel($inputChannel);
14
-		if(is_object($outputChannel)){
14
+		if (is_object($outputChannel)) {
15 15
 			$this->setOutputChannel($outputChannel);	
16 16
 		}
17 17
 		$this->registerCommand('ADD_ORDER', array($this, 'receiveOrder'));
18 18
 	}
19 19
 
20
-	protected function doReply(Message $message){
20
+	protected function doReply(Message $message) {
21 21
 		$drink = $message->getContent();
22 22
 		$nr = $drink->getOrderNumber();
23
-		if(!isset($this->preparedDrinks[$nr])){
23
+		if (!isset($this->preparedDrinks[$nr])) {
24 24
 			$this->preparedDrinks[$nr] = array();
25 25
 		}
26 26
 		$this->preparedDrinks[$drink->getOrderNumber()][] = $drink;
27
-		if(isset($this->orders[$nr]) 
28
-			&& $this->orders[$nr]->getTotalCount() == count($this->preparedDrinks[$nr])){
27
+		if (isset($this->orders[$nr]) 
28
+			&& $this->orders[$nr]->getTotalCount() == count($this->preparedDrinks[$nr])) {
29 29
 			$this->replyMessage($this->preparedDrinks[$nr]);
30 30
 			unset($this->preparedDrinks[$nr]);
31 31
 			echo PEIP_LINE_SEPARATOR.'DrinkAggregator : reply #'.$nr;	
32 32
 		}
33 33
 	}
34 34
 
35
-	public function receiveOrder(Order $order){
35
+	public function receiveOrder(Order $order) {
36 36
 		echo PEIP_LINE_SEPARATOR.'DrinkAggregator: received Order';
37 37
 		$this->orders[$order->getOrderNumber()] = $order;	
38 38
 	}	
Please login to merge, or discard this patch.
examples/Cafe/lib/messaging/DrinkRouter.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,9 +6,9 @@
 block discarded – undo
6 6
 class DrinkRouter 
7 7
 	extends Router {
8 8
 	
9
-	protected function selectChannels(Message $message){
9
+	protected function selectChannels(Message $message) {
10 10
 		$order = $message->getContent();
11
-		$channelName = $order['iced']  ? 'coldDrinks' : 'hotDrinks';
11
+		$channelName = $order['iced'] ? 'coldDrinks' : 'hotDrinks';
12 12
 		echo PEIP_LINE_SEPARATOR."DrinkRouter: routed to channel: $channelName";
13 13
 		return $channelName;
14 14
 	}	
Please login to merge, or discard this patch.
examples/Cafe/lib/messaging/OrderSplitter.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -5,15 +5,15 @@
 block discarded – undo
5 5
 
6 6
 class OrderSplitter extends MessageSplitter {
7 7
 
8
-	public function split(Message $message){
8
+	public function split(Message $message) {
9 9
 		$order = $message->getContent();
10 10
 		$orderItems = $order->getItems();
11 11
 		$items = array();
12
-		foreach($orderItems as $item){
12
+		foreach ($orderItems as $item) {
13 13
 			$nr = $item['number'];
14 14
 			unset($item['number']);
15 15
 			$item['order'] = $order->getOrderNumber();
16
-			for($x = 0; $x < $nr; $x++){
16
+			for ($x = 0; $x < $nr; $x++) {
17 17
 				$items[] = $item;	
18 18
 			}
19 19
 		}
Please login to merge, or discard this patch.
examples/Cafe/lib/model/Cafe.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
examples/HelloWorld/hello_world_scripted.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Factory/ServiceFactory.php 1 patch
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -23,11 +23,11 @@  discard block
 block discarded – undo
23 23
      * @param $config configuration of the service
24 24
      * @return object the initialized service instance
25 25
      */
26
-    public static function createService(array $config){
26
+    public static function createService(array $config) {
27 27
         $args = array();
28 28
         //build arguments for constructor
29
-        if(isset($config['constructor_arg'])){
30
-            foreach($config['constructor_arg'] as $arg){
29
+        if (isset($config['constructor_arg'])) {
30
+            foreach ($config['constructor_arg'] as $arg) {
31 31
                 $args[] = self::buildArg($arg);
32 32
             }
33 33
         }
@@ -44,21 +44,21 @@  discard block
 block discarded – undo
44 44
      * @param string $defaultClass class to create instance for if none is set in config
45 45
      * @return object build and modified srvice instance
46 46
      */
47
-    public static function doBuild($config, $arguments, $defaultClass = false){
47
+    public static function doBuild($config, $arguments, $defaultClass = false) {
48 48
         $cls = isset($config["class"]) ? trim((string)$config["class"]) : (string)$defaultClass;
49
-        if($cls != ''){
49
+        if ($cls != '') {
50 50
             try {
51
-                $constructor = isset($config["constructor"])?(string)$config["constructor"]:"";
52
-                if($constructor != '' && Test::assertMethod($cls, $constructor)){
51
+                $constructor = isset($config["constructor"]) ? (string)$config["constructor"] : "";
52
+                if ($constructor != '' && Test::assertMethod($cls, $constructor)) {
53 53
                     $service = call_user_func_array(array($cls, $constructor), $arguments);
54
-                }else{
54
+                }else {
55 55
                     $service = self::build($cls, $arguments);
56 56
                 }
57
-            }catch(\Exception $e){
57
+            } catch (\Exception $e) {
58 58
                 throw new \RuntimeException('Could not create Service "'.$cls.'" -> '.$e->getMessage());
59 59
             }
60 60
         }
61
-        if(is_object($service)){
61
+        if (is_object($service)) {
62 62
             return $service;
63 63
         }
64 64
         throw new \RuntimeException('Could not create Service "'.$cls.'". Class does not exist.');
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
      * @param array $arguments arguments for the constructor
76 76
      * @return object build and modified srvice instance
77 77
      */
78
-    public static function build($className, $arguments){
78
+    public static function build($className, $arguments) {
79 79
         return GenericBuilder::getInstance($className)->build($arguments);
80 80
     }
81 81
 
@@ -86,29 +86,29 @@  discard block
 block discarded – undo
86 86
      * @param object $config configuration object to create argument from.
87 87
      * @return mixed build argument
88 88
      */
89
-    protected function buildArg($config){
90
-        if(trim((string)$config['value']) != ''){
89
+    protected function buildArg($config) {
90
+        if (trim((string)$config['value']) != '') {
91 91
             $arg = (string)$config['value'];
92
-        }elseif($config->getName() == 'value'){
92
+        }elseif ($config->getName() == 'value') {
93 93
             $arg = (string)$config;
94
-        }elseif($config->getName() == 'list'){
94
+        }elseif ($config->getName() == 'list') {
95 95
             $arg = array();
96
-            foreach($config->children() as $entry){
97
-                if($entry->getName() == 'value'){
98
-                    if($entry['key']){
96
+            foreach ($config->children() as $entry) {
97
+                if ($entry->getName() == 'value') {
98
+                    if ($entry['key']) {
99 99
                         $arg[(string)$entry['key']] = (string)$entry;
100
-                    }else{
100
+                    }else {
101 101
                         $arg[] = (string)$entry;
102 102
                     }
103
-                }elseif($entry->getName() == 'service'){
103
+                }elseif ($entry->getName() == 'service') {
104 104
                     $arg[] = $this->provideService($entry);
105 105
                 }
106 106
             }
107
-        }elseif($config->getName() == 'service'){
107
+        }elseif ($config->getName() == 'service') {
108 108
             $arg = self::provideService($config);
109
-        }elseif($config->list){
109
+        }elseif ($config->list) {
110 110
             $arg = $this->buildArg($config->list);
111
-        }elseif($config->service){
111
+        }elseif ($config->service) {
112 112
             $arg = $this->buildArg($config->service);
113 113
         }
114 114
         return $arg;
@@ -126,24 +126,24 @@  discard block
 block discarded – undo
126 126
      * @param string $defaultClass class to create instance for if none is set in config
127 127
      * @return object build and modified srvice instance
128 128
      */
129
-    public static function buildAndModify(array $config, $arguments, $defaultClass = ""){
130
-        if((isset($config["class"]) && "" != (string)$config["class"])  || $defaultClass !== ""){
129
+    public static function buildAndModify(array $config, $arguments, $defaultClass = "") {
130
+        if ((isset($config["class"]) && "" != (string)$config["class"]) || $defaultClass !== "") {
131 131
              $service = ServiceFactory::doBuild($config, $arguments, $defaultClass);
132
-        }else{
132
+        }else {
133 133
             throw new \RuntimeException('Could not create Service. no class or reference given.');
134 134
         }
135
-        if(isset($config["ref_property"])){
135
+        if (isset($config["ref_property"])) {
136 136
             $service = $service->{(string)$config["ref_property"]};
137
-        }elseif(isset($config["ref_method"])){
137
+        }elseif (isset($config["ref_method"])) {
138 138
                 $args = array();
139
-            if(isset($config['argument'])){
140
-                        foreach($config['argument'] as $arg){
139
+            if (isset($config['argument'])) {
140
+                        foreach ($config['argument'] as $arg) {
141 141
                             $args[] = $this->buildArg($arg);
142 142
                         }
143 143
                 }
144 144
             $service = call_user_func_array(array($service, (string)$config["ref_method"]), $args);
145 145
         }
146
-        if(!is_object($service)){
146
+        if (!is_object($service)) {
147 147
             throw new \RuntimeException('Could not create Service.');
148 148
         }
149 149
         $service = self::modifyService($service, $config);
@@ -165,29 +165,29 @@  discard block
 block discarded – undo
165 165
      * @param object $config configuration to get the modification instructions from.
166 166
      * @return object the modificated service
167 167
      */
168
-    protected function modifyService($service, $config){        
168
+    protected function modifyService($service, $config) {        
169 169
         $config = is_array($config) ? new \ArrayObject($config) : $config;
170 170
         // set instance properties
171
-        if(isset($config->property)){
172
-            foreach($config->property as $property){
171
+        if (isset($config->property)) {
172
+            foreach ($config->property as $property) {
173 173
                 $arg = $this->buildArg($property);
174
-                if($arg){
174
+                if ($arg) {
175 175
                     $setter = self::getSetter($property);
176
-                    if($setter &&  self::hasPublicProperty($service, 'Method', $setter)){
176
+                    if ($setter && self::hasPublicProperty($service, 'Method', $setter)) {
177 177
                         $service->{$setter}($arg);
178
-                    }elseif(in_array($property, self::hasPublicProperty($service, 'Property', $setter))){
178
+                    }elseif (in_array($property, self::hasPublicProperty($service, 'Property', $setter))) {
179 179
                         $service->$setter = $arg;
180 180
                     }
181 181
                 }
182 182
             }
183 183
         }
184 184
         // call instance methods
185
-        if(isset($config->action)){
186
-            foreach($config->action as $action){
185
+        if (isset($config->action)) {
186
+            foreach ($config->action as $action) {
187 187
                 $method = (string)$action['method'] != '' ? (string)$action['method'] : NULL;
188
-                if($method && self::hasPublicProperty($service, 'Method', $method)){
188
+                if ($method && self::hasPublicProperty($service, 'Method', $method)) {
189 189
                     $args = array();
190
-                    foreach($action->children() as $argument){
190
+                    foreach ($action->children() as $argument) {
191 191
                         $args[] = $this->buildArg($argument);
192 192
                     }
193 193
                     call_user_func_array(array($service, (string)$action['method']), $args);
@@ -195,9 +195,9 @@  discard block
 block discarded – undo
195 195
             }
196 196
         }
197 197
         // register instance listeners
198
-        if($service instanceof \PEIP\INF\Event\Connectable){
199
-            if(isset($config->listener)){
200
-                foreach($config->listener as $listenerConf){
198
+        if ($service instanceof \PEIP\INF\Event\Connectable) {
199
+            if (isset($config->listener)) {
200
+                foreach ($config->listener as $listenerConf) {
201 201
                     $event = (string)$listenerConf['event'];
202 202
                     $listener = $this->provideService($listenerConf);
203 203
                     $service->connect($event, $listener);
Please login to merge, or discard this patch.