@@ -20,30 +20,30 @@ |
||
| 20 | 20 | |
| 21 | 21 | private function registerAmqpServices(Container $app) |
| 22 | 22 | { |
| 23 | - $app['amqp.client'] = function ($c) { |
|
| 23 | + $app['amqp.client'] = function($c) { |
|
| 24 | 24 | return new Pecl($c['configuration']); |
| 25 | 25 | }; |
| 26 | 26 | |
| 27 | - $app['amqp.workerProvider'] = function ($c) { |
|
| 27 | + $app['amqp.workerProvider'] = function($c) { |
|
| 28 | 28 | return new Pimple($c); |
| 29 | 29 | }; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | private function registerConsumers(Container $app) |
| 33 | 33 | { |
| 34 | - $app['amqp.consumers.simple'] = function () { |
|
| 34 | + $app['amqp.consumers.simple'] = function() { |
|
| 35 | 35 | return new Consumers\Simple(); |
| 36 | 36 | }; |
| 37 | 37 | |
| 38 | - $app['amqp.consumers.insomniac'] = function () { |
|
| 38 | + $app['amqp.consumers.insomniac'] = function() { |
|
| 39 | 39 | return new Consumers\Insomniac(); |
| 40 | 40 | }; |
| 41 | 41 | |
| 42 | - $app['amqp.consumers.retry'] = $app->protect(function (Container $c, $retries = null) { |
|
| 42 | + $app['amqp.consumers.retry'] = $app->protect(function(Container $c, $retries = null) { |
|
| 43 | 43 | return new Consumers\Retry($retries); |
| 44 | 44 | }); |
| 45 | 45 | |
| 46 | - $app['amqp.consumers.instantRetry'] = $app->protect(function (Container $c, $retries, $delayInSeconds) { |
|
| 46 | + $app['amqp.consumers.instantRetry'] = $app->protect(function(Container $c, $retries, $delayInSeconds) { |
|
| 47 | 47 | return new Consumers\InstantRetry($retries, $delayInSeconds); |
| 48 | 48 | }); |
| 49 | 49 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | public function applyHooks(MessageHookCollection $messageHookCollection) |
| 67 | 67 | { |
| 68 | - if(!empty($messageHookCollection)) |
|
| 68 | + if( ! empty($messageHookCollection)) |
|
| 69 | 69 | { |
| 70 | 70 | foreach($messageHookCollection as $messageHook) |
| 71 | 71 | { |
@@ -151,14 +151,14 @@ discard block |
||
| 151 | 151 | { |
| 152 | 152 | $retryHeader = $this->getHeader(\Puzzle\AMQP\Consumers\Retry::DEFAULT_RETRY_HEADER); |
| 153 | 153 | |
| 154 | - return (!empty($retryHeader) && (int) $retryHeader === $retryOccurence); |
|
| 154 | + return ( ! empty($retryHeader) && (int) $retryHeader === $retryOccurence); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | public function getRoutingKeyFromHeader() |
| 158 | 158 | { |
| 159 | 159 | $headers = $this->getHeaders(); |
| 160 | 160 | |
| 161 | - if(! array_key_exists('routing_key', $headers)) |
|
| 161 | + if( ! array_key_exists('routing_key', $headers)) |
|
| 162 | 162 | { |
| 163 | 163 | return null; |
| 164 | 164 | } |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | |
| 26 | 26 | $hooks = $this->workerContext->getMessageHooks(); |
| 27 | 27 | |
| 28 | - if(!empty($hooks)) |
|
| 28 | + if( ! empty($hooks)) |
|
| 29 | 29 | { |
| 30 | 30 | $message->applyHooks($hooks); |
| 31 | 31 | } |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | |
| 100 | 100 | public function deployInstances($numberOfInstance) |
| 101 | 101 | { |
| 102 | - if(! empty($numberOfInstance)) |
|
| 102 | + if( ! empty($numberOfInstance)) |
|
| 103 | 103 | { |
| 104 | 104 | $this->instances = (int) $numberOfInstance; |
| 105 | 105 | } |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | public function deployOn($servers) |
| 116 | 116 | { |
| 117 | - if(! empty($servers)) |
|
| 117 | + if( ! empty($servers)) |
|
| 118 | 118 | { |
| 119 | - if(! is_array($servers)) |
|
| 119 | + if( ! is_array($servers)) |
|
| 120 | 120 | { |
| 121 | 121 | $servers = [$servers]; |
| 122 | 122 | } |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | { |
| 28 | 28 | $retryHeader = $this->getHeader(\Puzzle\AMQP\Consumers\Retry::DEFAULT_RETRY_HEADER); |
| 29 | 29 | |
| 30 | - return (!empty($retryHeader) && (int) $retryHeader === $retryOccurence); |
|
| 30 | + return ( ! empty($retryHeader) && (int) $retryHeader === $retryOccurence); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | public function applyHooks(MessageHookCollection $messageHookCollection) |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | |
| 74 | 74 | public function setBody($body) |
| 75 | 75 | { |
| 76 | - if(! is_array($body)) |
|
| 76 | + if( ! is_array($body)) |
|
| 77 | 77 | { |
| 78 | 78 | $body = array($body); |
| 79 | 79 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | $timestamp = (new \DateTime("now"))->getTimestamp(); |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - return array_map(function ($value) use($timestamp) { |
|
| 129 | + return array_map(function($value) use($timestamp) { |
|
| 130 | 130 | |
| 131 | 131 | if($value instanceof \Closure) |
| 132 | 132 | { |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | $writableMessage = new static($routingKey); |
| 212 | 212 | |
| 213 | 213 | $decodedBody = $readableMessage->getDecodedBody(); |
| 214 | - if(! is_array($decodedBody)) |
|
| 214 | + if( ! is_array($decodedBody)) |
|
| 215 | 215 | { |
| 216 | 216 | $decodedBody = array($decodedBody); |
| 217 | 217 | } |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | $skippedAttributes = array('timestamp', 'headers', 'app_id', 'routing_key'); |
| 225 | 225 | foreach($attributes as $attributeName => $value) |
| 226 | 226 | { |
| 227 | - if(! in_array($attributeName, $skippedAttributes)) |
|
| 227 | + if( ! in_array($attributeName, $skippedAttributes)) |
|
| 228 | 228 | { |
| 229 | 229 | $writableMessage->setAttribute($attributeName, $value); |
| 230 | 230 | } |
@@ -43,12 +43,12 @@ |
||
| 43 | 43 | 'max_execution_time' => self::DEFAULT_MAX_EXECUTION_TIME, |
| 44 | 44 | ); |
| 45 | 45 | |
| 46 | - if(!empty($this->retries)) |
|
| 46 | + if( ! empty($this->retries)) |
|
| 47 | 47 | { |
| 48 | 48 | $options['instant_retry_attempts'] = $this->retries; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - if(!empty($this->delay)) |
|
| 51 | + if( ! empty($this->delay)) |
|
| 52 | 52 | { |
| 53 | 53 | $options['instant_retry_delay'] = $this->delay * 1000000; //computed in microseconds |
| 54 | 54 | } |
@@ -52,7 +52,7 @@ |
||
| 52 | 52 | 'retry_key_pattern' => sprintf(self::RETRY_ROUTING_KEY_PATTERN, $workerContext->queue), |
| 53 | 53 | ); |
| 54 | 54 | |
| 55 | - if(! empty($this->retries)) |
|
| 55 | + if( ! empty($this->retries)) |
|
| 56 | 56 | { |
| 57 | 57 | $options['retry_attempts'] = $this->retries; |
| 58 | 58 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | { |
| 39 | 39 | $workerNamePattern = $input->getArgument('workerNamePattern'); |
| 40 | 40 | |
| 41 | - if(!empty($workerNamePattern)) |
|
| 41 | + if( ! empty($workerNamePattern)) |
|
| 42 | 42 | { |
| 43 | 43 | $comment = sprintf('List of worker with following pattern: %s', $workerNamePattern); |
| 44 | 44 | $services = $this->workerProvider->listWithRegexFilter($workerNamePattern); |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | $output->writeln(sprintf('<comment>%s</comment>', $comment)); |
| 53 | 53 | |
| 54 | - if(empty($services) || !is_array($services)) |
|
| 54 | + if(empty($services) || ! is_array($services)) |
|
| 55 | 55 | { |
| 56 | 56 | $output->writeln('<error>No worker found</error>'); |
| 57 | 57 | return; |