@@ -68,20 +68,20 @@ |
||
| 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 | } |
@@ -43,9 +43,9 @@ |
||
| 43 | 43 | $task = $this->jsonMessageFactory->create($message->body); |
| 44 | 44 | call_user_func($this->callback, $task); |
| 45 | 45 | $message->delivery_info['channel']->basic_ack($message->delivery_info['delivery_tag']); |
| 46 | - } catch(InvalidJSONMessageException $e) { |
|
| 46 | + } catch (InvalidJSONMessageException $e) { |
|
| 47 | 47 | throw new ParseMessageException(json_encode($message->getBody()), 0, $e); |
| 48 | - } catch(Exception $e) { |
|
| 48 | + } catch (Exception $e) { |
|
| 49 | 49 | throw $e; |
| 50 | 50 | } |
| 51 | 51 | } |
@@ -42,10 +42,10 @@ discard block |
||
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | if (!isset($message['Body'])) { |
| 45 | - throw new ParseMessageException(json_encode($message),0, 'Undefined index key Body: ' . print_r($message, true)); |
|
| 45 | + throw new ParseMessageException(json_encode($message), 0, 'Undefined index key Body: ' . print_r($message, true)); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - try{ |
|
| 48 | + try { |
|
| 49 | 49 | |
| 50 | 50 | $body = json_decode($message['Body'], true); |
| 51 | 51 | |
@@ -55,9 +55,9 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | call_user_func($this->callback, $this->jsonMessageFactory->create($body['Message'])); |
| 57 | 57 | |
| 58 | - } catch(InvalidJSONMessageException $e) { |
|
| 59 | - throw new ParseMessageException(json_encode($message),0, $e); |
|
| 60 | - } catch(Exception $e) { |
|
| 58 | + } catch (InvalidJSONMessageException $e) { |
|
| 59 | + throw new ParseMessageException(json_encode($message), 0, $e); |
|
| 60 | + } catch (Exception $e) { |
|
| 61 | 61 | throw $e; |
| 62 | 62 | } |
| 63 | 63 | } |
@@ -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 | } |