Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
Nielsvanpach authored and actions-user committed Sep 7, 2021
1 parent c732f87 commit e8decf4
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 21 deletions.
8 changes: 4 additions & 4 deletions src/Enums/MetaData.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

class MetaData
{
const AGGREGATE_ROOT_UUID = 'aggregate-root-uuid';
const STORED_EVENT_ID = 'stored-event-id';
const CREATED_AT = 'created-at';
const AGGREGATE_ROOT_VERSION = 'aggregate-root-version';
public const AGGREGATE_ROOT_UUID = 'aggregate-root-uuid';
public const STORED_EVENT_ID = 'stored-event-id';
public const CREATED_AT = 'created-at';
public const AGGREGATE_ROOT_VERSION = 'aggregate-root-version';
}
2 changes: 1 addition & 1 deletion src/EventSerializers/JsonEventSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function __construct()
{
$encoders = [new JsonEncoder()];
$normalizers = array_map(
fn ($className) => new $className,
fn ($className) => new $className(),
config('event-sourcing.event_normalizers')
);

Expand Down
2 changes: 1 addition & 1 deletion src/Snapshots/EloquentSnapshotRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function __construct()
{
$this->snapshotModel = (string)config('event-sourcing.snapshot_model', EloquentSnapshot::class);

if (! new $this->snapshotModel instanceof EloquentSnapshot) {
if (! new $this->snapshotModel() instanceof EloquentSnapshot) {
throw new InvalidEloquentSnapshotModel("The class {$this->snapshotModel} must extend EloquentSnapshot");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __construct()
{
$this->storedEventModel = (string) config('event-sourcing.stored_event_model', EloquentStoredEvent::class);

if (! new $this->storedEventModel instanceof EloquentStoredEvent) {
if (! new $this->storedEventModel() instanceof EloquentStoredEvent) {
throw new InvalidEloquentStoredEventModel("The class {$this->storedEventModel} must extend EloquentStoredEvent");
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/Support/ModelIdentifierNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
class ModelIdentifierNormalizer implements NormalizerInterface, DenormalizerInterface
{
use SerializesAndRestoresModelIdentifiers;

/**
* @inheritdoc
*/
Expand All @@ -22,18 +22,18 @@ public function normalize($object, string $format = null, array $context = [])
if (! $this->supportsNormalization($object)) {
throw new InvalidArgumentException('Cannot serialize an object that is not a QueueableEntity or QueueableCollection in ModelIdentifierNormalizer.');
}

return $this->getSerializedPropertyValue($object);
}

/**
* @inheritdoc
*/
public function supportsNormalization($data, string $format = null)
{
return ($data instanceof QueueableEntity || $data instanceof QueueableCollection);
}

/**
* @inheritdoc
*/
Expand All @@ -42,10 +42,10 @@ public function denormalize($data, $class, string $format = null, array $context
$identifier = $data instanceof ModelIdentifier
? $data
: new ModelIdentifier($data['class'], $data['id'], $data['relations'], $data['connection']);

return $this->getRestoredPropertyValue($identifier);
}

/**
* @inheritdoc
*/
Expand All @@ -54,13 +54,13 @@ public function supportsDenormalization($data, $type, string $format = null)
return $this->normalizedDataIsModelIdentifier($data)
&& $this->isNormalizedToModelIdentifier($type);
}

protected function normalizedDataIsModelIdentifier($data): bool
{
return $data instanceof ModelIdentifier
|| isset($data['class'], $data['id'], $data['relations'], $data['connection']);
}

protected function isNormalizedToModelIdentifier($class): bool
{
return is_a($class, QueueableEntity::class, true)
Expand Down
4 changes: 2 additions & 2 deletions tests/AggregateRoots/AggregatePartialTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function test_entities()
->addItem('test 2')
->persist();

$this->assertDatabaseCount((new EloquentStoredEvent)->getTable(), 2);
$this->assertDatabaseCount((new EloquentStoredEvent())->getTable(), 2);

$cart::retrieve(self::CART_UUID);

Expand Down Expand Up @@ -87,7 +87,7 @@ public function addItem(string $name): self

public function clear(): self
{
$this->recordThat(new CartCleared);
$this->recordThat(new CartCleared());

return $this;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/AggregateRoots/CommandHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function __construct()

public function clear(ClearCart $clearCart): self
{
$this->recordThat(new CartClearedForCommand);
$this->recordThat(new CartClearedForCommand());

return $this;
}
Expand Down
6 changes: 3 additions & 3 deletions tests/EloquentStoredEventRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ public function it_can_get_the_latest_version_id_for_a_given_aggregate_uuid()
$this->assertEquals(1, $eloquentStoredEventRepository->getLatestAggregateVersion('uuid-2'));
$this->assertEquals(2, $eloquentStoredEventRepository->getLatestAggregateVersion('uuid-1'));
}

/** @test */
public function it_sets_the_original_event_on_persist()
{
$eloquentStoredEventRepository = app(EloquentStoredEventRepository::class);

$originalEvent = new MoneyAdded(100);
$storedEvent = $eloquentStoredEventRepository->persist($originalEvent, 'uuid-1', 1);

$this->assertSame($originalEvent, $storedEvent->event);
}
}

0 comments on commit e8decf4

Please sign in to comment.