@@ -39,11 +39,11 @@ |
||
| 39 | 39 | throw new ReaderException("Handling a message with no callback set"); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - try{ |
|
| 42 | + try { |
|
| 43 | 43 | $body = json_decode($message['Body'], true); |
| 44 | 44 | call_user_func($this->callback, $this->jsonMessageFactory->create($body['Message'])); |
| 45 | - } catch(Exception $e){ |
|
| 46 | - throw new ParseMessageException(json_encode($message),0, $e); |
|
| 45 | + } catch (Exception $e) { |
|
| 46 | + throw new ParseMessageException(json_encode($message), 0, $e); |
|
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | |
@@ -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 | } |
@@ -9,7 +9,7 @@ |
||
| 9 | 9 | * @param int $timeout |
| 10 | 10 | * @return void |
| 11 | 11 | */ |
| 12 | - public function read(callable $callback, $timeout=0); |
|
| 12 | + public function read(callable $callback, $timeout = 0); |
|
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | 15 | * Deletes all messages from the queue |
@@ -50,20 +50,20 @@ discard block |
||
| 50 | 50 | * @param int $timeout |
| 51 | 51 | * @throws DomainEventException |
| 52 | 52 | */ |
| 53 | - public function start($timeout=0) |
|
| 53 | + public function start($timeout = 0) |
|
| 54 | 54 | { |
| 55 | - if(!isset($this->subscriptors[0])) { |
|
| 55 | + if (!isset($this->subscriptors[0])) { |
|
| 56 | 56 | throw new DomainEventException('You must add at least 1 EventSubscriptor in order to publish start reading from queue.'); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - while(true) { |
|
| 59 | + while (true) { |
|
| 60 | 60 | try { |
| 61 | 61 | $this->queueReader->read(array($this, 'notify'), $timeout); |
| 62 | - } catch(ParseMessageException $e){ |
|
| 62 | + } catch (ParseMessageException $e) { |
|
| 63 | 63 | break; |
| 64 | - } catch(TimeoutReaderException $e) { |
|
| 64 | + } catch (TimeoutReaderException $e) { |
|
| 65 | 65 | break; |
| 66 | - } catch(GracefulStopException $e) { |
|
| 66 | + } catch (GracefulStopException $e) { |
|
| 67 | 67 | break; |
| 68 | 68 | } |
| 69 | 69 | } |
@@ -73,9 +73,9 @@ discard block |
||
| 73 | 73 | * @param int $timeout |
| 74 | 74 | * @throws DomainEventException |
| 75 | 75 | */ |
| 76 | - public function batch($timeout=0) |
|
| 76 | + public function batch($timeout = 0) |
|
| 77 | 77 | { |
| 78 | - if(!isset($this->subscriptors[0])) { |
|
| 78 | + if (!isset($this->subscriptors[0])) { |
|
| 79 | 79 | throw new DomainEventException('You must add at least 1 EventSubscriptor in order to publish start reading from queue.'); |
| 80 | 80 | } |
| 81 | 81 | |
@@ -88,8 +88,8 @@ discard block |
||
| 88 | 88 | public function notify(DomainEvent $domainEvent) |
| 89 | 89 | { |
| 90 | 90 | $this->logger->debug('Domain Event received, notifying subscribers'); |
| 91 | - foreach($this->subscriptors as $subscriptor) { |
|
| 92 | - if($subscriptor->isSubscribed($domainEvent)) { |
|
| 91 | + foreach ($this->subscriptors as $subscriptor) { |
|
| 92 | + if ($subscriptor->isSubscribed($domainEvent)) { |
|
| 93 | 93 | $subscriptor->notify($domainEvent); |
| 94 | 94 | } |
| 95 | 95 | } |