Completed
Push — refactor-quim ( 7d1438...7042f1 )
by Quim
08:44 queued 06:26
created
src/Infrastructure/AmqpLib/v26/RabbitMQ/Queue/Config/ConnectionConfig.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
     protected $password;
17 17
     protected $vHost;
18 18
 
19
-    public function __construct($host, $port, $user, $password, $vHost='/')
19
+    public function __construct($host, $port, $user, $password, $vHost = '/')
20 20
     {
21 21
         $this->host = $host;
22 22
         $this->port = $port;
Please login to merge, or discard this patch.
src/Infrastructure/AmqpLib/v26/RabbitMQ/Queue/DelayedQueueWriter.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
     {
68 68
         $this->delay = $delay;
69 69
         $this->exchangeName = $exchangeName;
70
-        $this->delayedExchangeName = self::DELAY_QUEUE_PREFIX.$this->delay.$this->exchangeName;
70
+        $this->delayedExchangeName = self::DELAY_QUEUE_PREFIX . $this->delay . $this->exchangeName;
71 71
         $this->logger = $logger;
72 72
         $this->channel = $channel;
73 73
     }
@@ -81,15 +81,15 @@  discard block
 block discarded – undo
81 81
     {
82 82
         $this->initialize();
83 83
         try {
84
-            foreach($messages as $message) {
84
+            foreach ($messages as $message) {
85 85
                 $encodedMessage = json_encode($message);
86 86
                 $this->logger->debug('Writing:' . $encodedMessage);
87 87
                 $msg = new AMQPMessage($encodedMessage, array('delivery_mode' => 2));
88 88
                 $this->channel->batch_basic_publish($msg, $this->delayedExchangeName, $message->getName());
89 89
             }
90 90
             $this->channel->publish_batch();
91
-        } catch(\Exception $exception) {
92
-            $this->logger->error('Error writing messages: '.$exception->getMessage());
91
+        } catch (\Exception $exception) {
92
+            $this->logger->error('Error writing messages: ' . $exception->getMessage());
93 93
             throw new WriterException($exception->getMessage(), $exception->getCode());
94 94
         }
95 95
     }
@@ -99,13 +99,13 @@  discard block
 block discarded – undo
99 99
      */
100 100
     protected function initialize()
101 101
     {
102
-        try{
103
-            $delayedQueue = self::DELAY_QUEUE_PREFIX.$this->delay.'Queue';
102
+        try {
103
+            $delayedQueue = self::DELAY_QUEUE_PREFIX . $this->delay . 'Queue';
104 104
 
105
-            $this->logger->info('Creating delayed exchange '.$this->delayedExchangeName);
105
+            $this->logger->info('Creating delayed exchange ' . $this->delayedExchangeName);
106 106
             // Delay Queue
107 107
             $this->channel->exchange_declare($this->delayedExchangeName, 'fanout', false, true, true);
108
-            $this->logger->info('Creating delayed queue '.$delayedQueue);
108
+            $this->logger->info('Creating delayed queue ' . $delayedQueue);
109 109
             $this->channel->queue_declare(
110 110
                 $delayedQueue,
111 111
                 false,
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
                 ]
121 121
             );
122 122
             $this->channel->queue_bind($delayedQueue, $this->delayedExchangeName);
123
-        } catch(\Exception $exception) {
124
-            $this->logger->error('Error writing delayed messages: '.$exception->getMessage());
123
+        } catch (\Exception $exception) {
124
+            $this->logger->error('Error writing delayed messages: ' . $exception->getMessage());
125 125
             throw new WriterException($exception->getMessage(), $exception->getCode());
126 126
         }
127 127
     }
Please login to merge, or discard this patch.
src/Domain/Task/Producer.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
40 40
      */
41 41
     public function produce()
42 42
     {
43
-        if(!isset($this->tasks[0])) {
43
+        if (!isset($this->tasks[0])) {
44 44
             throw new TaskException('You must add at least 1 Task before producing.');
45 45
         }
46 46
         $this->queueWriter->write($this->tasks);
Please login to merge, or discard this patch.
src/Domain/Event/Publisher.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
      */
42 42
     public function publish()
43 43
     {
44
-        if(!isset($this->events[0])) {
44
+        if (!isset($this->events[0])) {
45 45
             throw new DomainEventException('You must add at least 1 DomainEvent in order to publish to queue.');
46 46
         }
47 47
         $this->queueWriter->write($this->events);
Please login to merge, or discard this patch.
src/Domain/Queue/QueueReader.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,5 +17,5 @@
 block discarded – undo
17 17
      * @throws ReaderException
18 18
      * @return void
19 19
      */
20
-    public function read(callable $callback, $timeout=0);
20
+    public function read(callable $callback, $timeout = 0);
21 21
 }
22 22
\ No newline at end of file
Please login to merge, or discard this patch.
src/Domain/Task/Consumer.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,12 +20,12 @@
 block discarded – undo
20 20
         $this->queueReader = $queueReader;
21 21
     }
22 22
 
23
-    public function consume(callable $callback, $timeout=0)
23
+    public function consume(callable $callback, $timeout = 0)
24 24
     {
25
-        while(true) {
25
+        while (true) {
26 26
             try {
27 27
                 $this->consumeOnce($callback, $timeout);
28
-            } catch(TimeoutReaderException $e) {
28
+            } catch (TimeoutReaderException $e) {
29 29
                 break;
30 30
             }
31 31
         }
Please login to merge, or discard this patch.
src/Domain/Event/Subscriber.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -43,12 +43,12 @@  discard block
 block discarded – undo
43 43
         return $this;
44 44
     }
45 45
 
46
-    public function start($timeout=0)
46
+    public function start($timeout = 0)
47 47
     {
48
-        while(true) {
48
+        while (true) {
49 49
             try {
50 50
                 $this->processOne($timeout);
51
-            } catch(TimeoutReaderException $e) {
51
+            } catch (TimeoutReaderException $e) {
52 52
                 break;
53 53
             }
54 54
         }
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 
57 57
     public function processOne($timeout)
58 58
     {
59
-        if(!isset($this->subscriptors[0])) {
59
+        if (!isset($this->subscriptors[0])) {
60 60
             throw new DomainEventException('You must add at least 1 EventSubscriptor in order to publish start reading from queue.');
61 61
         }
62 62
         $this->queueReader->read(array($this, 'notify'), $timeout);
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
     public function notify(DomainEvent $domainEvent)
69 69
     {
70 70
         $this->logger->info('Domain Event received, notifying subscribers');
71
-        foreach($this->subscriptors as $subscriptor) {
72
-            if($subscriptor->isSubscribed($domainEvent)) {
71
+        foreach ($this->subscriptors as $subscriptor) {
72
+            if ($subscriptor->isSubscribed($domainEvent)) {
73 73
                 $subscriptor->notify($domainEvent);
74 74
             }
75 75
         }
Please login to merge, or discard this patch.
src/Infrastructure/AmqpLib/v26/RabbitMQ/Queue/QueueReader.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -96,13 +96,13 @@  discard block
 block discarded – undo
96 96
      * @throws ReaderException
97 97
      * @throws TimeoutReaderException
98 98
      */
99
-    public function read(callable $callback, $timeout=0)
99
+    public function read(callable $callback, $timeout = 0)
100 100
     {
101 101
         $this->initialize();
102 102
         $this->messageHandler->setCallback($callback);
103 103
         try {
104 104
             $this->channel->wait(null, false, $timeout);
105
-        } catch(\Exception $e) {
105
+        } catch (\Exception $e) {
106 106
             throw new TimeoutReaderException();
107 107
         }
108 108
     }
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
      */
113 113
     protected function initialize()
114 114
     {
115
-        if($this->channel) {
115
+        if ($this->channel) {
116 116
             return;
117 117
         }
118 118
         $this->logger->info('Connecting to RabbitMQ');
Please login to merge, or discard this patch.
src/Infrastructure/AmqpLib/v26/RabbitMQ/Queue/QueueWriter.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
         $this->initialize();
65 65
         try {
66 66
             $messagesWithDelay = [];
67
-            foreach($messages as $message) {
68
-                if($message->getDelay() > 0) {
67
+            foreach ($messages as $message) {
68
+                if ($message->getDelay() > 0) {
69 69
                     $messagesWithDelay[$message->getDelay()][] = $message;
70 70
                     continue;
71 71
                 }
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
                 $this->channel->batch_basic_publish($msg, $this->exchangeConfig->getName(), $message->getName());
76 76
             }
77 77
             $this->channel->publish_batch();
78
-            foreach($messagesWithDelay as $delay => $delayedMessages) {
79
-                if(!isset($this->delayedQueueWriterRegistry[$delay])) {
78
+            foreach ($messagesWithDelay as $delay => $delayedMessages) {
79
+                if (!isset($this->delayedQueueWriterRegistry[$delay])) {
80 80
                     $this->delayedQueueWriterRegistry[$delay] = new DelayedQueueWriter(
81 81
                         $this->exchangeConfig->getName(),
82 82
                         $delay,
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
                 }
87 87
                 $this->delayedQueueWriterRegistry[$delay]->write($delayedMessages);
88 88
             }
89
-        } catch(\Exception $exception) {
90
-            $this->logger->error('Error writing messages: '.$exception->getMessage());
89
+        } catch (\Exception $exception) {
90
+            $this->logger->error('Error writing messages: ' . $exception->getMessage());
91 91
             throw new WriterException($exception->getMessage(), $exception->getCode());
92 92
         }
93 93
     }
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
      */
98 98
     protected function initialize()
99 99
     {
100
-        if($this->channel) {
100
+        if ($this->channel) {
101 101
             return;
102 102
         }
103 103
         $this->logger->info('Connecting to RabbitMQ');
Please login to merge, or discard this patch.