@@ -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\EventStore\EventStreamNotFound; |
| 12 | 11 | use SmoothPhp\Contracts\Serialization\Serializer; |
@@ -53,10 +53,10 @@ discard block |
||
| 53 | 53 | public function load($id) |
| 54 | 54 | { |
| 55 | 55 | $rows = $this->db->table($this->eventStoreTableName) |
| 56 | - ->select(['uuid', 'playhead', 'metadata', 'payload', 'recorded_on']) |
|
| 57 | - ->where('uuid', $id) |
|
| 58 | - ->orderBy('playhead', 'asc') |
|
| 59 | - ->get(); |
|
| 56 | + ->select(['uuid', 'playhead', 'metadata', 'payload', 'recorded_on']) |
|
| 57 | + ->where('uuid', $id) |
|
| 58 | + ->orderBy('playhead', 'asc') |
|
| 59 | + ->get(); |
|
| 60 | 60 | $events = []; |
| 61 | 61 | |
| 62 | 62 | foreach ($rows as $row) { |
@@ -103,16 +103,16 @@ discard block |
||
| 103 | 103 | private function insertEvent(DomainMessage $domainMessage) |
| 104 | 104 | { |
| 105 | 105 | $this->db->table($this->eventStoreTableName) |
| 106 | - ->insert( |
|
| 107 | - [ |
|
| 108 | - 'uuid' => (string)$domainMessage->getId(), |
|
| 109 | - 'playhead' => $domainMessage->getPlayHead(), |
|
| 110 | - 'metadata' => json_encode($this->serializer->serialize($domainMessage->getMetadata())), |
|
| 111 | - 'payload' => json_encode($this->serializer->serialize($domainMessage->getPayload())), |
|
| 112 | - 'recorded_on' => (string)$domainMessage->getRecordedOn(), |
|
| 113 | - 'type' => $domainMessage->getType(), |
|
| 114 | - ] |
|
| 115 | - ); |
|
| 106 | + ->insert( |
|
| 107 | + [ |
|
| 108 | + 'uuid' => (string)$domainMessage->getId(), |
|
| 109 | + 'playhead' => $domainMessage->getPlayHead(), |
|
| 110 | + 'metadata' => json_encode($this->serializer->serialize($domainMessage->getMetadata())), |
|
| 111 | + 'payload' => json_encode($this->serializer->serialize($domainMessage->getPayload())), |
|
| 112 | + 'recorded_on' => (string)$domainMessage->getRecordedOn(), |
|
| 113 | + 'type' => $domainMessage->getType(), |
|
| 114 | + ] |
|
| 115 | + ); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -80,13 +80,13 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | public function append($id, DomainEventStream $eventStream) |
| 82 | 82 | { |
| 83 | - $id = (string)$id; //Used to thrown errors if ID will not cast to string |
|
| 83 | + $id = (string) $id; //Used to thrown errors if ID will not cast to string |
|
| 84 | 84 | |
| 85 | 85 | $this->db->beginTransaction(); |
| 86 | 86 | |
| 87 | 87 | try { |
| 88 | 88 | foreach ($eventStream as $domainMessage) { |
| 89 | - $this->insertEvent( $domainMessage); |
|
| 89 | + $this->insertEvent($domainMessage); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | $this->db->commit(); |
@@ -105,11 +105,11 @@ discard block |
||
| 105 | 105 | $this->db->table($this->eventStoreTableName) |
| 106 | 106 | ->insert( |
| 107 | 107 | [ |
| 108 | - 'uuid' => (string)$domainMessage->getId(), |
|
| 108 | + 'uuid' => (string) $domainMessage->getId(), |
|
| 109 | 109 | 'playhead' => $domainMessage->getPlayHead(), |
| 110 | 110 | 'metadata' => json_encode($this->serializer->serialize($domainMessage->getMetadata())), |
| 111 | 111 | 'payload' => json_encode($this->serializer->serialize($domainMessage->getPayload())), |
| 112 | - 'recorded_on' => (string)$domainMessage->getRecordedOn(), |
|
| 112 | + 'recorded_on' => (string) $domainMessage->getRecordedOn(), |
|
| 113 | 113 | 'type' => $domainMessage->getType(), |
| 114 | 114 | ] |
| 115 | 115 | ); |
@@ -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']), |
@@ -37,13 +37,13 @@ |
||
| 37 | 37 | public function handle(DomainMessage $domainMessage) |
| 38 | 38 | { |
| 39 | 39 | $this->queue->push(QueueToEventDispatcher::class, |
| 40 | - [ |
|
| 41 | - 'uuid' => (string)$domainMessage->getId(), |
|
| 42 | - 'playhead' => $domainMessage->getPlayHead(), |
|
| 43 | - 'metadata' => json_encode($this->serializer->serialize($domainMessage->getMetadata())), |
|
| 44 | - 'payload' => json_encode($this->serializer->serialize($domainMessage->getPayload())), |
|
| 45 | - 'recorded_on' => (string)$domainMessage->getRecordedOn(), |
|
| 46 | - 'type' => $domainMessage->getType(), |
|
| 47 | - ]); |
|
| 40 | + [ |
|
| 41 | + 'uuid' => (string)$domainMessage->getId(), |
|
| 42 | + 'playhead' => $domainMessage->getPlayHead(), |
|
| 43 | + 'metadata' => json_encode($this->serializer->serialize($domainMessage->getMetadata())), |
|
| 44 | + 'payload' => json_encode($this->serializer->serialize($domainMessage->getPayload())), |
|
| 45 | + 'recorded_on' => (string)$domainMessage->getRecordedOn(), |
|
| 46 | + 'type' => $domainMessage->getType(), |
|
| 47 | + ]); |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | \ No newline at end of file |
@@ -38,11 +38,11 @@ |
||
| 38 | 38 | { |
| 39 | 39 | $this->queue->push(QueueToEventDispatcher::class, |
| 40 | 40 | [ |
| 41 | - 'uuid' => (string)$domainMessage->getId(), |
|
| 41 | + 'uuid' => (string) $domainMessage->getId(), |
|
| 42 | 42 | 'playhead' => $domainMessage->getPlayHead(), |
| 43 | 43 | 'metadata' => json_encode($this->serializer->serialize($domainMessage->getMetadata())), |
| 44 | 44 | 'payload' => json_encode($this->serializer->serialize($domainMessage->getPayload())), |
| 45 | - 'recorded_on' => (string)$domainMessage->getRecordedOn(), |
|
| 45 | + 'recorded_on' => (string) $domainMessage->getRecordedOn(), |
|
| 46 | 46 | 'type' => $domainMessage->getType(), |
| 47 | 47 | ]); |
| 48 | 48 | } |
@@ -58,7 +58,7 @@ |
||
| 58 | 58 | |
| 59 | 59 | Schema::connection($this->config->get('cqrses.eventstore_connection')) |
| 60 | 60 | ->create($this->config->get('cqrses.eventstore_table'), |
| 61 | - function (Blueprint $table) { |
|
| 61 | + function(Blueprint $table) { |
|
| 62 | 62 | $table->increments('id'); |
| 63 | 63 | $table->string('uuid', 56); |
| 64 | 64 | $table->integer('playhead')->unsigned(); |
@@ -48,8 +48,8 @@ discard block |
||
| 48 | 48 | public function handle() |
| 49 | 49 | { |
| 50 | 50 | if ($this->option('force') == 'true' || $this->confirm("Are you sure you want to make a new table '{$this->config->get('cqrses.eventstore_table')}'" |
| 51 | - . " on connection '{$this->config->get('cqrses.eventstore_connection')}'" |
|
| 52 | - . " Do you wish to continue?") |
|
| 51 | + . " on connection '{$this->config->get('cqrses.eventstore_connection')}'" |
|
| 52 | + . " Do you wish to continue?") |
|
| 53 | 53 | ) { |
| 54 | 54 | return $this->buildEventStoreTable(); |
| 55 | 55 | } |
@@ -62,16 +62,16 @@ discard block |
||
| 62 | 62 | protected function buildEventStoreTable() |
| 63 | 63 | { |
| 64 | 64 | Schema::connection($this->config->get('cqrses.eventstore_connection')) |
| 65 | - ->create($this->config->get('cqrses.eventstore_table'), |
|
| 66 | - function (Blueprint $table) { |
|
| 67 | - $table->increments('id'); |
|
| 68 | - $table->string('uuid', 56); |
|
| 69 | - $table->integer('playhead')->unsigned(); |
|
| 70 | - $table->text('metadata'); |
|
| 71 | - $table->text('payload'); |
|
| 72 | - $table->string('recorded_on', 32); |
|
| 73 | - $table->text('type'); |
|
| 74 | - $table->unique(['uuid', 'playhead']); |
|
| 75 | - }); |
|
| 65 | + ->create($this->config->get('cqrses.eventstore_table'), |
|
| 66 | + function (Blueprint $table) { |
|
| 67 | + $table->increments('id'); |
|
| 68 | + $table->string('uuid', 56); |
|
| 69 | + $table->integer('playhead')->unsigned(); |
|
| 70 | + $table->text('metadata'); |
|
| 71 | + $table->text('payload'); |
|
| 72 | + $table->string('recorded_on', 32); |
|
| 73 | + $table->text('type'); |
|
| 74 | + $table->unique(['uuid', 'playhead']); |
|
| 75 | + }); |
|
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | \ No newline at end of file |
@@ -96,11 +96,11 @@ |
||
| 96 | 96 | $stub = file_get_contents($this->getStub()); |
| 97 | 97 | |
| 98 | 98 | $namespace = rtrim($this->config->get('cqrses.namespace') . $this->argument('aggregate') . '\\' . $this->getFolder(), |
| 99 | - '\\'); |
|
| 99 | + '\\'); |
|
| 100 | 100 | |
| 101 | 101 | $stub = $this->replaceStubVariable('namespace', |
| 102 | - $namespace, |
|
| 103 | - $stub); |
|
| 102 | + $namespace, |
|
| 103 | + $stub); |
|
| 104 | 104 | |
| 105 | 105 | foreach ($this->replacementVariables() as $variableName => $variableValue) { |
| 106 | 106 | $stub = $this->replaceStubVariable($variableName, $variableValue, $stub); |
@@ -53,16 +53,16 @@ discard block |
||
| 53 | 53 | public function handle() |
| 54 | 54 | { |
| 55 | 55 | |
| 56 | - $path = base_path() . '/' . $this->config->get('cqrses.path') . '/' . $this->argument('aggregate') . '/' . $this->getFolder() . '/'; |
|
| 56 | + $path = base_path().'/'.$this->config->get('cqrses.path').'/'.$this->argument('aggregate').'/'.$this->getFolder().'/'; |
|
| 57 | 57 | |
| 58 | 58 | if (!file_exists($path)) { |
| 59 | 59 | $this->makeDirectory($path); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - $fullPath = $path . $this->getClassName() . '.php'; |
|
| 62 | + $fullPath = $path.$this->getClassName().'.php'; |
|
| 63 | 63 | |
| 64 | 64 | if (file_exists($fullPath)) { |
| 65 | - $this->error($fullPath . ' Already Exists'); |
|
| 65 | + $this->error($fullPath.' Already Exists'); |
|
| 66 | 66 | |
| 67 | 67 | return; |
| 68 | 68 | } |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | { |
| 96 | 96 | $stub = file_get_contents($this->getStub()); |
| 97 | 97 | |
| 98 | - $namespace = rtrim($this->config->get('cqrses.namespace') . $this->argument('aggregate') . '\\' . $this->getFolder(), |
|
| 98 | + $namespace = rtrim($this->config->get('cqrses.namespace').$this->argument('aggregate').'\\'.$this->getFolder(), |
|
| 99 | 99 | '\\'); |
| 100 | 100 | |
| 101 | 101 | $stub = $this->replaceStubVariable('namespace', |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | protected function replaceStubVariable($variableName, $variableValue, $stub) |
| 118 | 118 | { |
| 119 | - $stub = str_replace('{{' . $variableName . '}}', $variableValue, $stub); |
|
| 119 | + $stub = str_replace('{{'.$variableName.'}}', $variableValue, $stub); |
|
| 120 | 120 | |
| 121 | 121 | return $stub; |
| 122 | 122 | } |
@@ -48,7 +48,7 @@ |
||
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | - * @return bool |
|
| 51 | + * @return boolean|null |
|
| 52 | 52 | */ |
| 53 | 53 | public function handle() |
| 54 | 54 | { |
@@ -7,7 +7,6 @@ |
||
| 7 | 7 | use Illuminate\Database\DatabaseManager; |
| 8 | 8 | use SmoothPhp\Contracts\EventDispatcher\EventDispatcher; |
| 9 | 9 | use SmoothPhp\Contracts\Serialization\Serializer; |
| 10 | -use SmoothPhp\Serialization\Exception\SerializedClassDoesNotExist; |
|
| 11 | 10 | |
| 12 | 11 | /** |
| 13 | 12 | * Class RebuildProjectionsCommand |
@@ -118,8 +118,8 @@ |
||
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | /** |
| 121 | - * @param $start |
|
| 122 | - * @param $take |
|
| 121 | + * @param integer $start |
|
| 122 | + * @param integer $take |
|
| 123 | 123 | * @return \stdClass |
| 124 | 124 | */ |
| 125 | 125 | private function getFromEventStore($start, $take) |
@@ -114,7 +114,7 @@ |
||
| 114 | 114 | } |
| 115 | 115 | $this->output->progressFinish(); |
| 116 | 116 | |
| 117 | - $this->output->write((memory_get_peak_usage(true) / 1024 / 1024) . " MiB", false); |
|
| 117 | + $this->output->write((memory_get_peak_usage(true) / 1024 / 1024)." MiB", false); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | /** |
@@ -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 | } |
@@ -46,11 +46,11 @@ |
||
| 46 | 46 | $this->queue->push( |
| 47 | 47 | QueueToEventDispatcherWithCommandId::class, |
| 48 | 48 | [ |
| 49 | - 'uuid' => (string)$domainMessage->getId(), |
|
| 49 | + 'uuid' => (string) $domainMessage->getId(), |
|
| 50 | 50 | 'playhead' => $domainMessage->getPlayHead(), |
| 51 | 51 | 'metadata' => json_encode($this->serializer->serialize($domainMessage->getMetadata())), |
| 52 | 52 | 'payload' => json_encode($this->serializer->serialize($domainMessage->getPayload())), |
| 53 | - 'recorded_on' => (string)$domainMessage->getRecordedOn(), |
|
| 53 | + 'recorded_on' => (string) $domainMessage->getRecordedOn(), |
|
| 54 | 54 | 'type' => $domainMessage->getType(), |
| 55 | 55 | 'command_id' => $this->notificationsCommandBus->getLastCommandId(), |
| 56 | 56 | ] |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | * PushEventsThroughQueue constructor. |
| 28 | 28 | * @param Queue $queue |
| 29 | 29 | * @param Serializer $serializer |
| 30 | - * @param StrongConsistencyCommandBusMiddleware|CommandBus $notificationsCommandBus |
|
| 30 | + * @param StrongConsistencyCommandBusMiddleware $notificationsCommandBus |
|
| 31 | 31 | */ |
| 32 | 32 | public function __construct( |
| 33 | 33 | Queue $queue, |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | foreach ($commands as $command) { |
| 19 | - while (!Cache::has((string)$command)) { |
|
| 19 | + while (!Cache::has((string) $command)) { |
|
| 20 | 20 | usleep(1000); |
| 21 | 21 | |
| 22 | 22 | if ($i > 8000) { |
@@ -33,6 +33,6 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | function uuid() |
| 35 | 35 | { |
| 36 | - return (string)\Ramsey\Uuid\Uuid::uuid4(); |
|
| 36 | + return (string) \Ramsey\Uuid\Uuid::uuid4(); |
|
| 37 | 37 | } |
| 38 | 38 | } |