@@ -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']), |
@@ -79,7 +79,7 @@ |
||
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
82 | - * @param $branch |
|
82 | + * @param string|null $branch |
|
83 | 83 | */ |
84 | 84 | protected function replaceEnvConfig($branch) |
85 | 85 | { |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | protected function getGitBranch() |
69 | 69 | { |
70 | 70 | $shellOutput = []; |
71 | - exec('git branch | ' . "grep ' * '", $shellOutput); |
|
71 | + exec('git branch | '."grep ' * '", $shellOutput); |
|
72 | 72 | foreach ($shellOutput as $line) { |
73 | 73 | if (strpos($line, '* ') !== false) { |
74 | 74 | return trim(strtolower(str_replace(['* ', '/'], ['', '-'], $line))); |
@@ -83,9 +83,9 @@ discard block |
||
83 | 83 | */ |
84 | 84 | protected function replaceEnvConfig($branch) |
85 | 85 | { |
86 | - $envFilePath = base_path() . '/.env'; |
|
86 | + $envFilePath = base_path().'/.env'; |
|
87 | 87 | |
88 | - $rebuildFunction = function ($data) use ($branch) { |
|
88 | + $rebuildFunction = function($data) use ($branch) { |
|
89 | 89 | if (stristr($data, 'DB_TABLE_EVENTSTORE')) { |
90 | 90 | return "DB_TABLE_EVENTSTORE={$branch}\n"; |
91 | 91 | } |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | return $data; |
94 | 94 | }; |
95 | 95 | |
96 | - $contentArray = array_map($rebuildFunction,file($envFilePath)); |
|
96 | + $contentArray = array_map($rebuildFunction, file($envFilePath)); |
|
97 | 97 | |
98 | - file_put_contents($envFilePath, implode('',$contentArray)); |
|
98 | + file_put_contents($envFilePath, implode('', $contentArray)); |
|
99 | 99 | } |
100 | 100 | } |
@@ -29,9 +29,9 @@ |
||
29 | 29 | */ |
30 | 30 | public function handle(DomainMessage $domainMessage) |
31 | 31 | { |
32 | - $name = explode('.',$domainMessage->getType()); |
|
32 | + $name = explode('.', $domainMessage->getType()); |
|
33 | 33 | |
34 | 34 | $name = preg_replace('/(?!^)[A-Z]{2,}(?=[A-Z][a-z])|[A-Z][a-z]/', ' $0', end($name)); |
35 | - $this->log->debug(trim(ucwords($name)) . " ({$domainMessage->getType()})"); |
|
35 | + $this->log->debug(trim(ucwords($name))." ({$domainMessage->getType()})"); |
|
36 | 36 | } |
37 | 37 | } |
38 | 38 | \ No newline at end of file |
@@ -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 | ); |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | public function handle() |
50 | 50 | { |
51 | 51 | if ($this->option('force') == 'true' || $this->confirm("Are you sure you want to make a new table '{$this->config->get('cqrses.eventstore_table')}'" |
52 | - . " on connection '{$this->config->get('cqrses.eventstore_connection')}'" |
|
53 | - . " Do you wish to continue?") |
|
52 | + . " on connection '{$this->config->get('cqrses.eventstore_connection')}'" |
|
53 | + . " Do you wish to continue?") |
|
54 | 54 | ) { |
55 | 55 | try { |
56 | 56 | return $this->buildEventStoreTable(); |
@@ -67,16 +67,16 @@ discard block |
||
67 | 67 | protected function buildEventStoreTable() |
68 | 68 | { |
69 | 69 | Schema::connection($this->config->get('cqrses.eventstore_connection')) |
70 | - ->create($this->config->get('cqrses.eventstore_table'), |
|
71 | - function (Blueprint $table) { |
|
72 | - $table->increments('id'); |
|
73 | - $table->string('uuid', 56); |
|
74 | - $table->integer('playhead')->unsigned(); |
|
75 | - $table->text('metadata'); |
|
76 | - $table->longText('payload'); |
|
77 | - $table->timestamp('recorded_on', 32)->nullable()->index(); |
|
78 | - $table->string('type', 255)->index(); |
|
79 | - $table->unique(['uuid', 'playhead']); |
|
80 | - }); |
|
70 | + ->create($this->config->get('cqrses.eventstore_table'), |
|
71 | + function (Blueprint $table) { |
|
72 | + $table->increments('id'); |
|
73 | + $table->string('uuid', 56); |
|
74 | + $table->integer('playhead')->unsigned(); |
|
75 | + $table->text('metadata'); |
|
76 | + $table->longText('payload'); |
|
77 | + $table->timestamp('recorded_on', 32)->nullable()->index(); |
|
78 | + $table->string('type', 255)->index(); |
|
79 | + $table->unique(['uuid', 'playhead']); |
|
80 | + }); |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | \ No newline at end of file |
@@ -68,7 +68,7 @@ |
||
68 | 68 | { |
69 | 69 | Schema::connection($this->config->get('cqrses.eventstore_connection')) |
70 | 70 | ->create($this->config->get('cqrses.eventstore_table'), |
71 | - function (Blueprint $table) { |
|
71 | + function(Blueprint $table) { |
|
72 | 72 | $table->increments('id'); |
73 | 73 | $table->string('uuid', 56); |
74 | 74 | $table->integer('playhead')->unsigned(); |
@@ -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; |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | public function load($id) |
55 | 55 | { |
56 | 56 | $rows = $this->db->table($this->eventStoreTableName) |
57 | - ->select(['uuid', 'playhead', 'metadata', 'payload', 'recorded_on']) |
|
58 | - ->where('uuid', $id) |
|
59 | - ->orderBy('playhead', 'asc') |
|
60 | - ->get(); |
|
57 | + ->select(['uuid', 'playhead', 'metadata', 'payload', 'recorded_on']) |
|
58 | + ->where('uuid', $id) |
|
59 | + ->orderBy('playhead', 'asc') |
|
60 | + ->get(); |
|
61 | 61 | $events = []; |
62 | 62 | |
63 | 63 | foreach ($rows as $row) { |
@@ -154,13 +154,13 @@ discard block |
||
154 | 154 | public function getEventsByType($eventTypes, $skip, $take) |
155 | 155 | { |
156 | 156 | $rows = $this->db->table($this->eventStoreTableName) |
157 | - ->select(['uuid', 'playhead', 'metadata', 'payload', 'recorded_on']) |
|
158 | - ->whereIn('type', $eventTypes) |
|
159 | - ->skip($skip) |
|
160 | - ->take($take) |
|
161 | - ->orderBy('recorded_on', 'asc') |
|
162 | - ->orderBy('playhead', 'asc') |
|
163 | - ->get(); |
|
157 | + ->select(['uuid', 'playhead', 'metadata', 'payload', 'recorded_on']) |
|
158 | + ->whereIn('type', $eventTypes) |
|
159 | + ->skip($skip) |
|
160 | + ->take($take) |
|
161 | + ->orderBy('recorded_on', 'asc') |
|
162 | + ->orderBy('playhead', 'asc') |
|
163 | + ->get(); |
|
164 | 164 | $events = []; |
165 | 165 | |
166 | 166 | foreach ($rows as $row) { |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function append($id, DomainEventStream $eventStream, bool $ignorePlayhead = false) |
83 | 83 | { |
84 | - $id = (string)$id; //Used to thrown errors if ID will not cast to string |
|
84 | + $id = (string) $id; //Used to thrown errors if ID will not cast to string |
|
85 | 85 | |
86 | 86 | $this->db->reconnect(); |
87 | 87 | $this->db->beginTransaction(); |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | } catch (\PDOException $ex) { |
112 | 112 | if ((string) $ex->getCode() === '23000') { |
113 | 113 | if ($ignorePlayhead) { |
114 | - $eventRow['playhead'] ++; |
|
114 | + $eventRow['playhead']++; |
|
115 | 115 | return $this->insertEvent($eventRow, true); |
116 | 116 | } |
117 | 117 | throw new DuplicateAggregatePlayhead($eventRow['uuid'], $eventRow['playhead']); |
@@ -178,11 +178,11 @@ discard block |
||
178 | 178 | private function domainMessageToArray(DomainMessage $domainMessage): array |
179 | 179 | { |
180 | 180 | return [ |
181 | - 'uuid' => (string)$domainMessage->getId(), |
|
181 | + 'uuid' => (string) $domainMessage->getId(), |
|
182 | 182 | 'playhead' => $domainMessage->getPlayHead(), |
183 | 183 | 'metadata' => json_encode($this->serializer->serialize($domainMessage->getMetadata())), |
184 | 184 | 'payload' => json_encode($this->serializer->serialize($domainMessage->getPayload())), |
185 | - 'recorded_on' => (string)$domainMessage->getRecordedOn(), |
|
185 | + 'recorded_on' => (string) $domainMessage->getRecordedOn(), |
|
186 | 186 | 'type' => $domainMessage->getType(), |
187 | 187 | ]; |
188 | 188 | } |
@@ -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 |
@@ -44,11 +44,11 @@ |
||
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())), |
51 | - 'recorded_on' => (string)$domainMessage->getRecordedOn(), |
|
51 | + 'recorded_on' => (string) $domainMessage->getRecordedOn(), |
|
52 | 52 | 'type' => $domainMessage->getType(), |
53 | 53 | ], |
54 | 54 | $this->config->get('cqrses.queue_name', 'default') |