@@ -34,7 +34,7 @@ |
||
34 | 34 | */ |
35 | 35 | public static function create($region) |
36 | 36 | { |
37 | - $sqs = SqsClient::factory(['region' => $region, 'version' => '2012-11-05',]); |
|
37 | + $sqs = SqsClient::factory(['region' => $region, 'version' => '2012-11-05', ]); |
|
38 | 38 | $sns = SnsClient::factory(['region' => $region, 'version' => '2010-03-31']); |
39 | 39 | |
40 | 40 | return new self($sqs, $sns); |
@@ -12,7 +12,7 @@ |
||
12 | 12 | * @return void |
13 | 13 | * @throws ReaderException |
14 | 14 | */ |
15 | - public function read(callable $callback, $timeout=0); |
|
15 | + public function read(callable $callback, $timeout = 0); |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * Deletes all messages from the queue |
@@ -50,16 +50,16 @@ discard block |
||
50 | 50 | * @throws DomainEventException |
51 | 51 | * @throws \Cmp\Queues\Domain\Queue\Exception\ReaderException |
52 | 52 | */ |
53 | - public function start($timeout=0) |
|
53 | + public function start($timeout = 0) |
|
54 | 54 | { |
55 | 55 | $this->checkHasSubscriptors(); |
56 | 56 | |
57 | - while(true) { |
|
57 | + while (true) { |
|
58 | 58 | try { |
59 | 59 | $this->queueReader->read(array($this, 'notify'), $timeout); |
60 | - } catch(TimeoutReaderException $e) { |
|
60 | + } catch (TimeoutReaderException $e) { |
|
61 | 61 | break; |
62 | - } catch(GracefulStopException $e) { |
|
62 | + } catch (GracefulStopException $e) { |
|
63 | 63 | break; |
64 | 64 | } |
65 | 65 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @throws DomainEventException |
71 | 71 | * @throws \Cmp\Queues\Domain\Queue\Exception\ReaderException |
72 | 72 | */ |
73 | - public function batch($timeout=0) |
|
73 | + public function batch($timeout = 0) |
|
74 | 74 | { |
75 | 75 | $this->checkHasSubscriptors(); |
76 | 76 | |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | public function notify(DomainEvent $domainEvent) |
84 | 84 | { |
85 | 85 | $this->logger->debug('Domain Event received, notifying subscribers'); |
86 | - foreach($this->subscriptors as $subscriptor) { |
|
87 | - if($subscriptor->isSubscribed($domainEvent)) { |
|
86 | + foreach ($this->subscriptors as $subscriptor) { |
|
87 | + if ($subscriptor->isSubscribed($domainEvent)) { |
|
88 | 88 | $subscriptor->notify($domainEvent); |
89 | 89 | } |
90 | 90 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | */ |
104 | 104 | private function checkHasSubscriptors() |
105 | 105 | { |
106 | - if(empty($this->getSubscriptors())) { |
|
106 | + if (empty($this->getSubscriptors())) { |
|
107 | 107 | throw new DomainEventException('You must add at least 1 EventSubscriptor in order to publish start reading from queue.'); |
108 | 108 | } |
109 | 109 | } |
@@ -68,20 +68,20 @@ discard block |
||
68 | 68 | * @throws ReaderException |
69 | 69 | * @throws TimeoutReaderException |
70 | 70 | */ |
71 | - public function read(callable $callback, $timeout=0) |
|
71 | + public function read(callable $callback, $timeout = 0) |
|
72 | 72 | { |
73 | 73 | $this->messageHandler->setCallback($callback); |
74 | 74 | |
75 | 75 | try { |
76 | 76 | $this->consume($timeout); |
77 | - } catch(ParseMessageException $e){ |
|
77 | + } catch (ParseMessageException $e) { |
|
78 | 78 | throw $e; |
79 | - } catch(GracefulStopException $e) { |
|
79 | + } catch (GracefulStopException $e) { |
|
80 | 80 | $this->logger->info("Gracefully stopping the AWS queue reader", ["exception" => $e]); |
81 | 81 | throw $e; |
82 | - } catch(TimeoutReaderException $e) { |
|
82 | + } catch (TimeoutReaderException $e) { |
|
83 | 83 | throw $e; |
84 | - } catch(\Exception $e) { |
|
84 | + } catch (\Exception $e) { |
|
85 | 85 | throw new ReaderException("Error occurred while reading", 0, $e); |
86 | 86 | } |
87 | 87 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | $messages = isset($result['Messages']) ? $result['Messages'] : []; |
120 | 120 | foreach ($messages as $message) { |
121 | 121 | $response = $this->messageHandler->handleMessage($message); |
122 | - if(is_null($response) || !is_bool($response) || $response) { |
|
122 | + if (is_null($response) || !is_bool($response) || $response) { |
|
123 | 123 | $this->sqs->deleteMessage(['QueueUrl' => $this->queueUrl, 'ReceiptHandle' => $message['ReceiptHandle']]); |
124 | 124 | } |
125 | 125 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | throw new ReaderException("Handling a message with no callback set"); |
43 | 43 | } |
44 | 44 | |
45 | - try{ |
|
45 | + try { |
|
46 | 46 | |
47 | 47 | if (!isset($message['Body'])) { |
48 | 48 | throw new InvalidJSONMessageException('Undefined index key Body: ' . print_r($message, true)); |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | |
57 | 57 | return call_user_func($this->callback, $this->jsonMessageFactory->create($body['Message'])); |
58 | 58 | |
59 | - } catch(InvalidJSONMessageException $e) { |
|
60 | - throw new ParseMessageException(json_encode($message),0, $e); |
|
59 | + } catch (InvalidJSONMessageException $e) { |
|
60 | + throw new ParseMessageException(json_encode($message), 0, $e); |
|
61 | 61 | } |
62 | 62 | } |
63 | 63 |
@@ -42,10 +42,10 @@ |
||
42 | 42 | try { |
43 | 43 | $task = $this->jsonMessageFactory->create($message->body); |
44 | 44 | $response = call_user_func($this->callback, $task); |
45 | - if(is_null($response) || !is_bool($response) || $response) { |
|
45 | + if (is_null($response) || !is_bool($response) || $response) { |
|
46 | 46 | $message->delivery_info['channel']->basic_ack($message->delivery_info['delivery_tag']); |
47 | 47 | } |
48 | - } catch(InvalidJSONMessageException $e) { |
|
48 | + } catch (InvalidJSONMessageException $e) { |
|
49 | 49 | throw new ParseMessageException(json_encode($message->getBody()), 0, $e); |
50 | 50 | } |
51 | 51 | } |