@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | * |
| 214 | 214 | * @access protected |
| 215 | 215 | * @param object $config configuration object to create arguments from. |
| 216 | - * @return mixed build arguments |
|
| 216 | + * @return \PEIP\INF\Channel\Channel[] build arguments |
|
| 217 | 217 | */ |
| 218 | 218 | protected function getReplyHandlerArguments($config){ |
| 219 | 219 | $args = array( |
@@ -259,6 +259,7 @@ discard block |
||
| 259 | 259 | * @access protected |
| 260 | 260 | * @param string the configuration type ofthe channel (e.g.: 'reply', 'request') |
| 261 | 261 | * @param object $config configuration object to return channel from. |
| 262 | + * @param string $type |
|
| 262 | 263 | * @return \PEIP\INF\Channel\Channel reply-channel |
| 263 | 264 | */ |
| 264 | 265 | public function doGetChannel($type, $config){ |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * @param object $config configuration object for the pollable channel. |
| 43 | 43 | * @return \PEIP\INF\Channel\Channel the created pollable channel instance |
| 44 | 44 | */ |
| 45 | - public function createChannel($config){ |
|
| 45 | + public function createChannel($config) { |
|
| 46 | 46 | return $this->doCreateChannel($config, '\PEIP\Channel\PollableChannel'); |
| 47 | 47 | } |
| 48 | 48 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * @param object $config configuration object for the subscribable channel. |
| 55 | 55 | * @return \PEIP\INF\Channel\Channel the created subscribable channel instance |
| 56 | 56 | */ |
| 57 | - public function createSubscribableChannel($config){ |
|
| 57 | + public function createSubscribableChannel($config) { |
|
| 58 | 58 | return $this->doCreateChannel($config, '\PEIP\Channel\PublishSubscribeChannel'); |
| 59 | 59 | } |
| 60 | 60 | |
@@ -67,9 +67,9 @@ discard block |
||
| 67 | 67 | * @param $additionalArguments additional arguments for the channel constructor (without first arg = id) |
| 68 | 68 | * @return \PEIP\INF\Channel\Channel the created channel instance |
| 69 | 69 | */ |
| 70 | - public function doCreateChannel($config, $defaultChannelClass, array $additionalArguments = array()){ |
|
| 70 | + public function doCreateChannel($config, $defaultChannelClass, array $additionalArguments = array()) { |
|
| 71 | 71 | $id = (string)$config['id']; |
| 72 | - if($id != ''){ |
|
| 72 | + if ($id != '') { |
|
| 73 | 73 | array_unshift($additionalArguments, $id); |
| 74 | 74 | $channel = $this->buildAndModify($config, $additionalArguments, $defaultChannelClass); |
| 75 | 75 | //$this->channelRegistry->register($channel); |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | * @param string $defaultClass the class to use if none is set in config. |
| 88 | 88 | * @return object the gateway instance |
| 89 | 89 | */ |
| 90 | - public function createGateway($config, $defaultClass = false){ |
|
| 90 | + public function createGateway($config, $defaultClass = false) { |
|
| 91 | 91 | $args = array( |
| 92 | 92 | $this->getRequestChannel($config), |
| 93 | 93 | $this->getReplyChannel($config) |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * @param string $defaultClass the class to use if none is set in config. |
| 112 | 112 | * @return object the router instance |
| 113 | 113 | */ |
| 114 | - public function createRouter($config, $defaultClass = false){ |
|
| 114 | + public function createRouter($config, $defaultClass = false) { |
|
| 115 | 115 | $resolver = $config['channel_resolver'] ? (string)$config['channel_resolver'] : $this->channelRegistry; |
| 116 | 116 | return $this->buildAndModify($config, array( |
| 117 | 117 | $resolver, |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | * @param object $config configuration object for the splitter. |
| 129 | 129 | * @return object the splitter instance |
| 130 | 130 | */ |
| 131 | - public function createSplitter($config){ |
|
| 131 | + public function createSplitter($config) { |
|
| 132 | 132 | return $this->createReplyMessageHandler($config); |
| 133 | 133 | } |
| 134 | 134 | |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | * @param object $config configuration object for the transformer. |
| 142 | 142 | * @return object the transformer instance |
| 143 | 143 | */ |
| 144 | - public function createTransformer($config){ |
|
| 144 | + public function createTransformer($config) { |
|
| 145 | 145 | return $this->createReplyMessageHandler($config); |
| 146 | 146 | } |
| 147 | 147 | |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | * @param object $config configuration object for the aggregator. |
| 155 | 155 | * @return object the aggregator instance |
| 156 | 156 | */ |
| 157 | - public function createAggregator($config){ |
|
| 157 | + public function createAggregator($config) { |
|
| 158 | 158 | return $this->createReplyMessageHandler($config); |
| 159 | 159 | } |
| 160 | 160 | |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | * @param object $config configuration object for the wiretap. |
| 168 | 168 | * @return object the wiretap instance |
| 169 | 169 | */ |
| 170 | - public function createWiretap($config){ |
|
| 170 | + public function createWiretap($config) { |
|
| 171 | 171 | return $this->createReplyMessageHandler($config, '\PEIP\Listener\Wiretap'); |
| 172 | 172 | } |
| 173 | 173 | |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | * @param string $defaultClass the class to use if none is set in config. |
| 181 | 181 | * @return object the reply-message-handler instance |
| 182 | 182 | */ |
| 183 | - public function createReplyMessageHandler($config, $defaultClass = false){ |
|
| 183 | + public function createReplyMessageHandler($config, $defaultClass = false) { |
|
| 184 | 184 | return $this->buildAndModify($config, $this->getReplyHandlerArguments($config), $defaultClass); |
| 185 | 185 | } |
| 186 | 186 | |
@@ -193,12 +193,12 @@ discard block |
||
| 193 | 193 | * @param string $defaultClass the class to use if none is set in config. |
| 194 | 194 | * @return object the service-activator instance |
| 195 | 195 | */ |
| 196 | - public function createServiceActivator($config, $defaultClass = false){ |
|
| 196 | + public function createServiceActivator($config, $defaultClass = false) { |
|
| 197 | 197 | $method = (string)$config['method']; |
| 198 | 198 | $service = $this->context->getServiceProvider()->provideService((string)$config['ref']); |
| 199 | - if($method && $service){ |
|
| 199 | + if ($method && $service) { |
|
| 200 | 200 | $args = $this->getReplyHandlerArguments($config); |
| 201 | - array_unshift($args,array( |
|
| 201 | + array_unshift($args, array( |
|
| 202 | 202 | $service, |
| 203 | 203 | $method |
| 204 | 204 | )); |
@@ -215,12 +215,12 @@ discard block |
||
| 215 | 215 | * @param object $config configuration object to create arguments from. |
| 216 | 216 | * @return mixed build arguments |
| 217 | 217 | */ |
| 218 | - protected function getReplyHandlerArguments($config){ |
|
| 218 | + protected function getReplyHandlerArguments($config) { |
|
| 219 | 219 | $args = array( |
| 220 | 220 | $this->doGetChannel('input', $config), |
| 221 | 221 | $this->doGetChannel('output', $config) |
| 222 | 222 | ); |
| 223 | - if($args[0] == NULL){ |
|
| 223 | + if ($args[0] == NULL) { |
|
| 224 | 224 | throw new \RuntimeException('Could not receive input channel.'); |
| 225 | 225 | } |
| 226 | 226 | return $args; |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | * @param object $config configuration object to return request-channel from. |
| 236 | 236 | * @return \PEIP\INF\Channel\Channel request-channel |
| 237 | 237 | */ |
| 238 | - protected function getRequestChannel($config){ |
|
| 238 | + protected function getRequestChannel($config) { |
|
| 239 | 239 | return $this->doGetChannel('request', $config); |
| 240 | 240 | } |
| 241 | 241 | |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | * @param object $config configuration object to return reply-channel from. |
| 249 | 249 | * @return \PEIP\INF\Channel\Channel reply-channel |
| 250 | 250 | */ |
| 251 | - protected function getReplyChannel($config){ |
|
| 251 | + protected function getReplyChannel($config) { |
|
| 252 | 252 | return $this->doGetChannel('reply', $config); |
| 253 | 253 | } |
| 254 | 254 | |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | * @param object $config configuration object to return channel from. |
| 262 | 262 | * @return \PEIP\INF\Channel\Channel reply-channel |
| 263 | 263 | */ |
| 264 | - public function doGetChannel($type, $config){ |
|
| 264 | + public function doGetChannel($type, $config) { |
|
| 265 | 265 | $channelName = isset($config[$type."_channel"]) |
| 266 | 266 | ? $config[$type."_channel"] |
| 267 | 267 | : $config["default_".$type."_channel"]; |
@@ -22,42 +22,42 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | class XMLArrayTranslator { |
| 24 | 24 | |
| 25 | - public static function translate($content){ |
|
| 25 | + public static function translate($content) { |
|
| 26 | 26 | try { |
| 27 | 27 | $node = simplexml_load_string($content); |
| 28 | 28 | // fix for hhvm |
| 29 | - if(!($node instanceof \SimpleXMLElement)){ |
|
| 29 | + if (!($node instanceof \SimpleXMLElement)) { |
|
| 30 | 30 | throw new \Exception('loading XML failed'); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | } |
| 34 | - catch(\Exception $e){ |
|
| 34 | + catch (\Exception $e) { |
|
| 35 | 35 | return false; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | return self::doTranslate($node); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - protected static function doTranslate(\SimpleXMLElement $node){ |
|
| 41 | + protected static function doTranslate(\SimpleXMLElement $node) { |
|
| 42 | 42 | |
| 43 | 43 | $array = array(); |
| 44 | 44 | $array['type'] = $node['type'] |
| 45 | 45 | ? (string)$node['type'] |
| 46 | 46 | : (string)$node->getName(); |
| 47 | 47 | $value = (string)$node; |
| 48 | - if($value != ''){ |
|
| 48 | + if ($value != '') { |
|
| 49 | 49 | $array['value'] = $value; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - foreach($node->attributes() as $name=>$value){ |
|
| 52 | + foreach ($node->attributes() as $name=>$value) { |
|
| 53 | 53 | $array[$name] = (string)$value; |
| 54 | 54 | } |
| 55 | - foreach($node->children() as $nr=>$child){ |
|
| 55 | + foreach ($node->children() as $nr=>$child) { |
|
| 56 | 56 | $name = $child->getName(); |
| 57 | 57 | $res = self::doTranslate($child); |
| 58 | 58 | |
| 59 | - if(isset($array[$name])){ |
|
| 60 | - if(is_string($array[$name])){ |
|
| 59 | + if (isset($array[$name])) { |
|
| 60 | + if (is_string($array[$name])) { |
|
| 61 | 61 | $array[$name] = array( |
| 62 | 62 | array( |
| 63 | 63 | 'type'=>$name, |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | ) |
| 66 | 66 | ); |
| 67 | 67 | } |
| 68 | - }else{ |
|
| 68 | + }else { |
|
| 69 | 69 | $array[$name] = array(); |
| 70 | 70 | } |
| 71 | 71 | $array[$name][] = $res; |
@@ -30,8 +30,7 @@ discard block |
||
| 30 | 30 | throw new \Exception('loading XML failed'); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - } |
|
| 34 | - catch(\Exception $e){ |
|
| 33 | + } catch(\Exception $e){ |
|
| 35 | 34 | return false; |
| 36 | 35 | } |
| 37 | 36 | |
@@ -65,7 +64,7 @@ discard block |
||
| 65 | 64 | ) |
| 66 | 65 | ); |
| 67 | 66 | } |
| 68 | - }else{ |
|
| 67 | + } else{ |
|
| 69 | 68 | $array[$name] = array(); |
| 70 | 69 | } |
| 71 | 70 | $array[$name][] = $res; |
@@ -19,21 +19,21 @@ |
||
| 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(); |
@@ -76,11 +76,11 @@ |
||
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | - * returns all headers of the message |
|
| 80 | - * |
|
| 81 | - * @access public |
|
| 82 | - * @return ArrayAccess ArrayAccess object of headers |
|
| 83 | - */ |
|
| 79 | + * returns all headers of the message |
|
| 80 | + * |
|
| 81 | + * @access public |
|
| 82 | + * @return ArrayAccess ArrayAccess object of headers |
|
| 83 | + */ |
|
| 84 | 84 | public function getHeaders(){ |
| 85 | 85 | return (array) $this->headers; |
| 86 | 86 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
@@ -134,12 +134,10 @@ |
||
| 134 | 134 | $res = false; |
| 135 | 135 | try { |
| 136 | 136 | $res = (string)$this->getContent(); |
| 137 | - } |
|
| 138 | - catch(\Exception $e){ |
|
| 137 | + } catch(\Exception $e){ |
|
| 139 | 138 | try { |
| 140 | 139 | $res = get_class($this->getContent()); |
| 141 | - } |
|
| 142 | - catch(\Exception $e){ |
|
| 140 | + } catch(\Exception $e){ |
|
| 143 | 141 | return ""; |
| 144 | 142 | } |
| 145 | 143 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
@@ -37,8 +37,8 @@ discard block |
||
| 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 |
||
| 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 | } |
@@ -54,7 +54,7 @@ |
||
| 54 | 54 | public function execute(){ |
| 55 | 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 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -56,11 +56,11 @@ discard block |
||
| 56 | 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 | } |
@@ -79,8 +79,7 @@ discard block |
||
| 79 | 79 | } |
| 80 | 80 | try { |
| 81 | 81 | return call_user_func_array($this->callable, array($message, $channel, $sent)); |
| 82 | - } |
|
| 83 | - catch(\Exception $e){ |
|
| 82 | + } catch(\Exception $e){ |
|
| 84 | 83 | throw new \RuntimeException('Unable to call Callable: '.$e->getMessage()); |
| 85 | 84 | } |
| 86 | 85 | } |
@@ -36,7 +36,7 @@ |
||
| 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 | } |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * @param $key |
| 33 | 33 | * @return |
| 34 | 34 | */ |
| 35 | - protected function hasInternalValue($key){ |
|
| 35 | + protected function hasInternalValue($key) { |
|
| 36 | 36 | return array_key_exists($key, $this->internalValues); |
| 37 | 37 | } |
| 38 | 38 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * @param $key |
| 43 | 43 | * @return |
| 44 | 44 | */ |
| 45 | - protected function getInternalValue($key){ |
|
| 45 | + protected function getInternalValue($key) { |
|
| 46 | 46 | return array_key_exists($key, $this->internalValues) ? $this->internalValues[$key] : NULL; |
| 47 | 47 | } |
| 48 | 48 | |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * @param $key |
| 53 | 53 | * @return |
| 54 | 54 | */ |
| 55 | - protected function deleteInternalValue($key){ |
|
| 55 | + protected function deleteInternalValue($key) { |
|
| 56 | 56 | unset($this->internalValues[$key]); |
| 57 | 57 | } |
| 58 | 58 | |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | * @param $value |
| 64 | 64 | * @return |
| 65 | 65 | */ |
| 66 | - protected function setInternalValue($key, $value){ |
|
| 66 | + protected function setInternalValue($key, $value) { |
|
| 67 | 67 | $this->internalValues[$key] = $value; |
| 68 | 68 | } |
| 69 | 69 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * @param $internalValues |
| 81 | 81 | * @return |
| 82 | 82 | */ |
| 83 | - protected function setInternalValues(array $internalValues){ |
|
| 83 | + protected function setInternalValues(array $internalValues) { |
|
| 84 | 84 | $this->internalValues = $internalValues; |
| 85 | 85 | } |
| 86 | 86 | |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * @access protected |
| 96 | 96 | * @return |
| 97 | 97 | */ |
| 98 | - protected function getInternalValues(){ |
|
| 98 | + protected function getInternalValues() { |
|
| 99 | 99 | return $this->internalValues; |
| 100 | 100 | } |
| 101 | 101 | |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | * @access protected |
| 105 | 105 | * @return |
| 106 | 106 | */ |
| 107 | - protected function addInternalValues(){ |
|
| 107 | + protected function addInternalValues() { |
|
| 108 | 108 | array_merge($this->internalValues, $internalValues); |
| 109 | 109 | } |
| 110 | 110 | |