@@ -35,7 +35,7 @@ |
||
35 | 35 | */ |
36 | 36 | public function fire($job, $data) |
37 | 37 | { |
38 | - $payload = (json_decode($data['payload'],true)); |
|
38 | + $payload = (json_decode($data['payload'], true)); |
|
39 | 39 | |
40 | 40 | $event = call_user_func([ |
41 | 41 | str_replace('.', '\\', $data['type']), |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | public function register() |
39 | 39 | { |
40 | 40 | |
41 | - $configPath = __DIR__ . '/../config/cqrses.php'; |
|
41 | + $configPath = __DIR__.'/../config/cqrses.php'; |
|
42 | 42 | $this->mergeConfigFrom($configPath, 'cqrses'); |
43 | 43 | |
44 | 44 | $app = $this->app; |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | |
67 | 67 | public function boot() |
68 | 68 | { |
69 | - $configPath = __DIR__ . '/../config/cqrses.php'; |
|
69 | + $configPath = __DIR__.'/../config/cqrses.php'; |
|
70 | 70 | $this->publishes([$configPath => $this->getConfigPath()], 'config'); |
71 | 71 | |
72 | 72 | } |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | |
113 | 113 | $this->app->singleton( |
114 | 114 | CommandBus::class, |
115 | - function () use ($middlewareChain) { |
|
115 | + function() use ($middlewareChain) { |
|
116 | 116 | return new \SmoothPhp\CommandBus\CommandBus($middlewareChain); |
117 | 117 | } |
118 | 118 | ); |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | if ($app['config']->get('cqrses.laravel_eventstore_enabled')) { |
136 | 136 | $app->bind( |
137 | 137 | EventStore::class, |
138 | - function (Application $application) { |
|
138 | + function(Application $application) { |
|
139 | 139 | return new LaravelEventStore( |
140 | 140 | $application->make(DatabaseManager::class), |
141 | 141 | $application->make(Serializer::class), |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | { |
155 | 155 | $app->singleton( |
156 | 156 | EventBus::class, |
157 | - function (Application $application) { |
|
157 | + function(Application $application) { |
|
158 | 158 | $eventBus = $application->make($application['config']->get('cqrses.event_bus')); |
159 | 159 | |
160 | 160 | foreach ($application['config']->get('cqrses.event_bus_listeners') as $listener) { |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | { |
174 | 174 | $app->singleton( |
175 | 175 | EventDispatcher::class, |
176 | - function (Application $application) { |
|
176 | + function(Application $application) { |
|
177 | 177 | /** @var EventDispatcher $dispatcher */ |
178 | 178 | $dispatcher = $application->make($application['config']->get('cqrses.event_dispatcher')); |
179 | 179 | |
@@ -193,13 +193,13 @@ discard block |
||
193 | 193 | protected function getProjectionEventSubscribers(Application $app) |
194 | 194 | { |
195 | 195 | return collect($app['config']->get('cqrses.projections_service_providers'))->map( |
196 | - function ($projectionsServiceProvider) use ($app) { |
|
196 | + function($projectionsServiceProvider) use ($app) { |
|
197 | 197 | return $app->make($projectionsServiceProvider); |
198 | 198 | } |
199 | 199 | )->map( |
200 | - function (ProjectionServiceProvider $projectServiceProvider) use ($app) { |
|
200 | + function(ProjectionServiceProvider $projectServiceProvider) use ($app) { |
|
201 | 201 | return collect($projectServiceProvider->getProjections())->map( |
202 | - function ($projection) use ($app) { |
|
202 | + function($projection) use ($app) { |
|
203 | 203 | return $app->make($projection); |
204 | 204 | } |
205 | 205 | ); |
@@ -6,7 +6,6 @@ |
||
6 | 6 | use Illuminate\Database\QueryException; |
7 | 7 | use SmoothPhp\Contracts\Domain\DomainEventStream; |
8 | 8 | use SmoothPhp\Contracts\Domain\DomainMessage; |
9 | -use SmoothPhp\Contracts\EventStore\DomainEventStreamInterface; |
|
10 | 9 | use SmoothPhp\Contracts\EventStore\EventStore; |
11 | 10 | use SmoothPhp\Contracts\Serialization\Serializer; |
12 | 11 | use SmoothPhp\Domain\DateTime; |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | public function load(string $id) : DomainEventStream |
56 | 56 | { |
57 | 57 | $rows = $this->db->table($this->eventStoreTableName) |
58 | - ->select(['uuid', 'playhead', 'metadata', 'payload', 'recorded_on']) |
|
59 | - ->where('uuid', $id) |
|
60 | - ->orderBy('playhead', 'asc') |
|
61 | - ->get(); |
|
58 | + ->select(['uuid', 'playhead', 'metadata', 'payload', 'recorded_on']) |
|
59 | + ->where('uuid', $id) |
|
60 | + ->orderBy('playhead', 'asc') |
|
61 | + ->get(); |
|
62 | 62 | $events = []; |
63 | 63 | |
64 | 64 | foreach ($rows as $row) { |
@@ -152,12 +152,12 @@ discard block |
||
152 | 152 | $rows = $this->db->table( |
153 | 153 | $this->db->raw("`{$this->eventStoreTableName}` FORCE INDEX (eventstore_type_index)") |
154 | 154 | ) |
155 | - ->select(['id', 'uuid', 'playhead', 'metadata', 'payload', 'recorded_on']) |
|
156 | - ->whereIn('type', $eventTypes) |
|
157 | - ->where('id', '>', $lastId) |
|
158 | - ->take($take) |
|
159 | - ->orderBy('id') |
|
160 | - ->get(); |
|
155 | + ->select(['id', 'uuid', 'playhead', 'metadata', 'payload', 'recorded_on']) |
|
156 | + ->whereIn('type', $eventTypes) |
|
157 | + ->where('id', '>', $lastId) |
|
158 | + ->take($take) |
|
159 | + ->orderBy('id') |
|
160 | + ->get(); |
|
161 | 161 | $events = []; |
162 | 162 | foreach ($rows as $row) { |
163 | 163 | $events[] = $this->deserializeEvent($row); |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | public function deleteStream(string $streamId) : void |
191 | 191 | { |
192 | 192 | $this->db->table($this->eventStoreTableName) |
193 | - ->where('uuid', $streamId) |
|
194 | - ->delete(); |
|
193 | + ->where('uuid', $streamId) |
|
194 | + ->delete(); |
|
195 | 195 | } |
196 | 196 | } |
197 | 197 | \ No newline at end of file |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | try { |
108 | 108 | $this->db->table($this->eventStoreTableName)->insert($eventRow); |
109 | 109 | } catch (\PDOException $ex) { |
110 | - if ((string)$ex->getCode() === '23000') { |
|
110 | + if ((string) $ex->getCode() === '23000') { |
|
111 | 111 | throw new DuplicateAggregatePlayhead($eventRow['uuid'], $eventRow['playhead'], $ex); |
112 | 112 | } |
113 | 113 | throw $ex; |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | private function domainMessageToArray(DomainMessage $domainMessage) : array |
176 | 176 | { |
177 | 177 | return [ |
178 | - 'uuid' => (string)$domainMessage->getId(), |
|
178 | + 'uuid' => (string) $domainMessage->getId(), |
|
179 | 179 | 'playhead' => $domainMessage->getPlayHead(), |
180 | 180 | 'metadata' => json_encode($this->serializer->serialize($domainMessage->getMetadata())), |
181 | 181 | 'payload' => json_encode($this->serializer->serialize($domainMessage->getPayload())), |
@@ -30,7 +30,7 @@ |
||
30 | 30 | * PushEventsThroughQueue constructor. |
31 | 31 | * @param Queue $queue |
32 | 32 | * @param Serializer $serializer |
33 | - * @param StrongConsistencyCommandBusMiddleware|CommandBus $notificationsCommandBus |
|
33 | + * @param StrongConsistencyCommandBusMiddleware $notificationsCommandBus |
|
34 | 34 | * @param Repository $config |
35 | 35 | */ |
36 | 36 | public function __construct( |
@@ -54,11 +54,11 @@ |
||
54 | 54 | $this->queue->push( |
55 | 55 | QueueToEventDispatcherWithCommandId::class, |
56 | 56 | [ |
57 | - 'uuid' => (string)$domainMessage->getId(), |
|
57 | + 'uuid' => (string) $domainMessage->getId(), |
|
58 | 58 | 'playhead' => $domainMessage->getPlayHead(), |
59 | 59 | 'metadata' => json_encode($this->serializer->serialize($domainMessage->getMetadata())), |
60 | 60 | 'payload' => json_encode($this->serializer->serialize($domainMessage->getPayload())), |
61 | - 'recorded_on' => (string)$domainMessage->getRecordedOn(), |
|
61 | + 'recorded_on' => (string) $domainMessage->getRecordedOn(), |
|
62 | 62 | 'type' => $domainMessage->getType(), |
63 | 63 | 'command_id' => $this->notificationsCommandBus->getLastCommandId(), |
64 | 64 | ], |
@@ -22,7 +22,7 @@ |
||
22 | 22 | */ |
23 | 23 | public function execute(Command $command, callable $next) |
24 | 24 | { |
25 | - $this->lastCommandId = (string)$command; |
|
25 | + $this->lastCommandId = (string) $command; |
|
26 | 26 | $next($command); |
27 | 27 | } |
28 | 28 |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | |
18 | 18 | $limit = time() + $timeout; |
19 | 19 | foreach ($commands as $command) { |
20 | - while (!Cache::has((string)$command)) { |
|
20 | + while (!Cache::has((string) $command)) { |
|
21 | 21 | usleep(1000); |
22 | 22 | |
23 | 23 | if (time() > $limit) { |
@@ -34,6 +34,6 @@ discard block |
||
34 | 34 | */ |
35 | 35 | function uuid() |
36 | 36 | { |
37 | - return (string)\Ramsey\Uuid\Uuid::uuid4(); |
|
37 | + return (string) \Ramsey\Uuid\Uuid::uuid4(); |
|
38 | 38 | } |
39 | 39 | } |
@@ -25,7 +25,7 @@ |
||
25 | 25 | public function test_pushing_event_to_queue() |
26 | 26 | { |
27 | 27 | $container = new Container(); |
28 | - // $container->bind(\Illuminate\Contracts\Container\Container::class, $container); |
|
28 | + // $container->bind(\Illuminate\Contracts\Container\Container::class, $container); |
|
29 | 29 | $queue = new Queue($container); |
30 | 30 | |
31 | 31 |
@@ -1,4 +1,4 @@ |
||
1 | -<?php declare (strict_types=1); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace Tests\EventDispatcher; |
4 | 4 |
@@ -44,7 +44,7 @@ |
||
44 | 44 | $this->queue->push( |
45 | 45 | QueueToEventDispatcher::class, |
46 | 46 | [ |
47 | - 'uuid' => (string)$domainMessage->getId(), |
|
47 | + 'uuid' => (string) $domainMessage->getId(), |
|
48 | 48 | 'playhead' => $domainMessage->getPlayHead(), |
49 | 49 | 'metadata' => json_encode($this->serializer->serialize($domainMessage->getMetadata())), |
50 | 50 | 'payload' => json_encode($this->serializer->serialize($domainMessage->getPayload())), |
@@ -71,20 +71,20 @@ |
||
71 | 71 | protected function buildEventStoreTable() |
72 | 72 | { |
73 | 73 | Schema::connection($this->config->get('cqrses.eventstore_connection')) |
74 | - ->create( |
|
75 | - $this->config->get('cqrses.eventstore_table'), |
|
76 | - function (Blueprint $table) { |
|
77 | - $table->increments('id'); |
|
78 | - $table->string('uuid', 56); |
|
79 | - $table->integer('playhead')->unsigned(); |
|
80 | - $table->text('metadata'); |
|
81 | - $table->longText('payload'); |
|
82 | - $table->timestamp('recorded_on')->nullable()->index(); |
|
83 | - $table->string('type', 255)->index(); |
|
84 | - $table->unique(['uuid', 'playhead']); |
|
74 | + ->create( |
|
75 | + $this->config->get('cqrses.eventstore_table'), |
|
76 | + function (Blueprint $table) { |
|
77 | + $table->increments('id'); |
|
78 | + $table->string('uuid', 56); |
|
79 | + $table->integer('playhead')->unsigned(); |
|
80 | + $table->text('metadata'); |
|
81 | + $table->longText('payload'); |
|
82 | + $table->timestamp('recorded_on')->nullable()->index(); |
|
83 | + $table->string('type', 255)->index(); |
|
84 | + $table->unique(['uuid', 'playhead']); |
|
85 | 85 | |
86 | - $table->index(['id', 'type']); |
|
87 | - } |
|
88 | - ); |
|
86 | + $table->index(['id', 'type']); |
|
87 | + } |
|
88 | + ); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | \ No newline at end of file |
@@ -73,7 +73,7 @@ |
||
73 | 73 | Schema::connection($this->config->get('cqrses.eventstore_connection')) |
74 | 74 | ->create( |
75 | 75 | $this->config->get('cqrses.eventstore_table'), |
76 | - function (Blueprint $table) { |
|
76 | + function(Blueprint $table) { |
|
77 | 77 | $table->increments('id'); |
78 | 78 | $table->string('uuid', 56); |
79 | 79 | $table->integer('playhead')->unsigned(); |