Skip to content

Commit

Permalink
improve naming
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidBadura committed Jan 2, 2024
1 parent 4838498 commit 33e5b56
Show file tree
Hide file tree
Showing 19 changed files with 63 additions and 63 deletions.
10 changes: 5 additions & 5 deletions src/Aggregate/AggregateRootAttributeBehaviour.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ public function aggregateRootId(): AggregateRootId

$reflection = new ReflectionProperty($this, $metadata->idProperty);

/** @var mixed $aggregateId */
$aggregateId = $reflection->getValue($this);
/** @var mixed $aggregateRootId */
$aggregateRootId = $reflection->getValue($this);

if (!$aggregateId instanceof AggregateRootId) {
throw new AggregateIdNotSupported($this::class, $aggregateId);
if (!$aggregateRootId instanceof AggregateRootId) {

Check warning on line 49 in src/Aggregate/AggregateRootAttributeBehaviour.php

View workflow job for this annotation

GitHub Actions / Mutation tests (locked, 8.3, ubuntu-latest)

Escaped Mutant for Mutator "InstanceOf_": --- Original +++ New @@ @@ $reflection = new ReflectionProperty($this, $metadata->idProperty); /** @var mixed $aggregateRootId */ $aggregateRootId = $reflection->getValue($this); - if (!$aggregateRootId instanceof AggregateRootId) { + if (!true) { throw new AggregateRootIdNotSupported($this::class, $aggregateRootId); } return $this->cachedAggregateRootId = $aggregateRootId; } }
throw new AggregateRootIdNotSupported($this::class, $aggregateRootId);
}

return $this->cachedAggregateRootId = $aggregateId;
return $this->cachedAggregateRootId = $aggregateRootId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
use function get_debug_type;
use function sprintf;

final class AggregateIdNotSupported extends RuntimeException
final class AggregateRootIdNotSupported extends RuntimeException
{
/** @param class-string $className */
public function __construct(string $className, mixed $value)
/** @param class-string $aggregateRootClass */
public function __construct(string $aggregateRootClass, mixed $value)
{
parent::__construct(
sprintf(
'aggregate id in class "%s" must be instance of "%s", got "%s"',
$className,
'aggregate root id in class "%s" must be instance of "%s", got "%s"',
$aggregateRootClass,
AggregateRootId::class,
get_debug_type($value),
),
Expand Down
6 changes: 3 additions & 3 deletions src/Aggregate/ApplyMethodNotFound.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
final class ApplyMethodNotFound extends AggregateException
{
/**
* @param class-string<AggregateRoot> $aggregate
* @param class-string<AggregateRoot> $aggregateRootClass
* @param class-string $event
*/
public function __construct(string $aggregate, string $event)
public function __construct(string $aggregateRootClass, string $event)
{
parent::__construct(
sprintf(
'Apply method in "%s" could not be found for the event "%s"',
$aggregate,
$aggregateRootClass,
$event,
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@

final class AggregateRootClassNotRegistered extends MetadataException
{
public function __construct(string $eventClass)
public function __construct(string $aggregateRootClass)
{
parent::__construct(
sprintf(
'Aggregate root class "%s" is not registered',
$eventClass,
$aggregateRootClass,
),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

use function sprintf;

final class AggregateIdNotFound extends RuntimeException
final class AggregateRootIdNotFound extends RuntimeException
{
public function __construct(string $className)
public function __construct(string $aggregateRootClass)
{
parent::__construct(sprintf('class %s has no property marked as aggregate id', $className));
parent::__construct(sprintf('class %s has no property marked as aggregate root id', $aggregateRootClass));
}
}
4 changes: 2 additions & 2 deletions src/Metadata/AggregateRoot/AggregateRootNameNotRegistered.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@

final class AggregateRootNameNotRegistered extends MetadataException
{
public function __construct(string $evenName)
public function __construct(string $name)
{
parent::__construct(
sprintf(
'Aggregate root name "%s" is not registered',
$evenName,
$name,
),
);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Metadata/AggregateRoot/AggregateWithoutMetadataAware.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

final class AggregateWithoutMetadataAware extends MetadataException
{
/** @param class-string $class */
public function __construct(string $class)
/** @param class-string $aggregateRootClass */
public function __construct(string $aggregateRootClass)
{
parent::__construct(sprintf('The class "%s" does not implements AggregateRootMetadataAware', $class));
parent::__construct(sprintf('The class "%s" does not implements AggregateRootMetadataAware', $aggregateRootClass));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private function findIdProperty(ReflectionClass $reflector): string
return $property->getName();
}

throw new AggregateIdNotFound($reflector->getName());
throw new AggregateRootIdNotFound($reflector->getName());
}

private function findSnapshot(ReflectionClass $reflector): Snapshot|null
Expand Down
6 changes: 3 additions & 3 deletions src/Metadata/AggregateRoot/DuplicateApplyMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
final class DuplicateApplyMethod extends MetadataException
{
/**
* @param class-string<AggregateRoot> $aggregate
* @param class-string<AggregateRoot> $aggregateRootClass
* @param class-string $event
*/
public function __construct(string $aggregate, string $event, string $fistMethod, string $secondMethod)
public function __construct(string $aggregateRootClass, string $event, string $fistMethod, string $secondMethod)
{
parent::__construct(
sprintf(
'Two methods "%s" and "%s" on the aggregate "%s" want to apply the same event "%s". Only one method can apply an event.',
$fistMethod,
$secondMethod,
$aggregate,
$aggregateRootClass,
$event,
),
);
Expand Down
6 changes: 3 additions & 3 deletions src/Metadata/AggregateRoot/NoAggregateRoot.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

final class NoAggregateRoot extends MetadataException
{
/** @param class-string $class */
public function __construct(string $class)
/** @param class-string $aggregateRootClass */
public function __construct(string $aggregateRootClass)
{
parent::__construct(sprintf('The class "%s" does not implement AggregateRoot', $class));
parent::__construct(sprintf('The class "%s" does not implement AggregateRoot', $aggregateRootClass));
}
}
4 changes: 2 additions & 2 deletions src/Metadata/Event/EventNameNotRegistered.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@

final class EventNameNotRegistered extends MetadataException
{
public function __construct(string $evenName)
public function __construct(string $name)
{
parent::__construct(
sprintf(
'Event name "%s" is not registered',
$evenName,
$name,
),
);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Repository/AggregateDetached.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@

final class AggregateDetached extends RepositoryException
{
/** @param class-string<AggregateRoot> $aggregateClass */
public function __construct(string $aggregateClass, AggregateRootId $aggregateId)
/** @param class-string<AggregateRoot> $aggregateRootClass */
public function __construct(string $aggregateRootClass, AggregateRootId $aggregateRootId)
{
parent::__construct(
sprintf(
'An error occurred while saving the aggregate "%s" with the ID "%s", causing the uncommitted events to be lost. Please reload the aggregate.',
$aggregateClass,
$aggregateId->toString(),
$aggregateRootClass,
$aggregateRootId->toString(),
),
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Repository/AggregateNotFound.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

final class AggregateNotFound extends RepositoryException
{
public function __construct(string $aggregateClass, AggregateRootId $id)
public function __construct(string $aggregateRootClass, AggregateRootId $rootId)
{
parent::__construct(sprintf('aggregate "%s::%s" not found', $aggregateClass, $id->toString()));
parent::__construct(sprintf('aggregate "%s::%s" not found', $aggregateRootClass, $rootId->toString()));
}
}
8 changes: 4 additions & 4 deletions src/Repository/AggregateUnknown.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@

final class AggregateUnknown extends RepositoryException
{
/** @param class-string<AggregateRoot> $aggregateClass */
public function __construct(string $aggregateClass, AggregateRootId $aggregateId)
/** @param class-string<AggregateRoot> $aggregateRootClass */
public function __construct(string $aggregateRootClass, AggregateRootId $aggregateRootId)
{
parent::__construct(
sprintf(
'The aggregate %s with the ID "%s" was not loaded from this repository. Please reload the aggregate.',
$aggregateClass,
$aggregateId->toString(),
$aggregateRootClass,
$aggregateRootId->toString(),
),
);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Repository/PlayheadMismatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@

final class PlayheadMismatch extends RepositoryException
{
public function __construct(string $aggregateClass, AggregateRootId $aggregateId, int $playhead, int $eventCount)
public function __construct(string $aggregateRootClass, AggregateRootId $aggregateRootId, int $playhead, int $eventCount)
{
parent::__construct(sprintf(
'There is a mismatch between the playhead [%s] and the event count [%s] for the aggregate [%s] with the id [%s]',
$playhead,
$eventCount,
$aggregateClass,
$aggregateId->toString(),
$aggregateRootClass,
$aggregateRootId->toString(),
));
}
}
16 changes: 8 additions & 8 deletions src/Repository/SnapshotRebuildFailed.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@

final class SnapshotRebuildFailed extends RepositoryException
{
/** @param class-string<AggregateRoot> $aggregateClass */
/** @param class-string<AggregateRoot> $aggregateRootClass */
public function __construct(
private string $aggregateClass,
private AggregateRootId $aggregateId,
private string $aggregateRootClass,
private AggregateRootId $aggregateRootId,
Throwable $previous,
) {
parent::__construct(
sprintf(
'Rebuild from snapshot of aggregate "%s" with the id "%s" failed',
$aggregateClass,
$aggregateId->toString(),
$aggregateRootClass,
$aggregateRootId->toString(),
),
0,
$previous,
Expand All @@ -32,11 +32,11 @@ public function __construct(
/** @return class-string<AggregateRoot> */
public function aggregateClass(): string
{
return $this->aggregateClass;
return $this->aggregateRootClass;
}

public function aggregateId(): AggregateRootId
public function aggregateRootId(): AggregateRootId
{
return $this->aggregateId;
return $this->aggregateRootId;
}
}
6 changes: 3 additions & 3 deletions src/Repository/WrongAggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
final class WrongAggregate extends RepositoryException
{
/**
* @param class-string $aggregateClass
* @param class-string $aggregateRootClass
* @param class-string $expected
*/
public function __construct(string $aggregateClass, string $expected)
public function __construct(string $aggregateRootClass, string $expected)
{
parent::__construct(
sprintf('Wrong aggregate given: got "%s" but expected "%s"', $aggregateClass, $expected),
sprintf('Wrong aggregate given: got "%s" but expected "%s"', $aggregateRootClass, $expected),
);
}
}
6 changes: 3 additions & 3 deletions src/Snapshot/SnapshotNotConfigured.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@

final class SnapshotNotConfigured extends SnapshotException
{
/** @param class-string<AggregateRoot> $aggregateClass */
public function __construct(string $aggregateClass)
/** @param class-string<AggregateRoot> $aggregateRootClass */
public function __construct(string $aggregateRootClass)
{
parent::__construct(
sprintf(
'Missing snapshot configuration for the aggregate class "%s"',
$aggregateClass,
$aggregateRootClass,
),
);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Snapshot/SnapshotNotFound.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@

final class SnapshotNotFound extends SnapshotException
{
/** @param class-string<AggregateRoot> $aggregate */
public function __construct(string $aggregate, AggregateRootId $id, Throwable|null $previous = null)
/** @param class-string<AggregateRoot> $aggregateRootClass */
public function __construct(string $aggregateRootClass, AggregateRootId $rootId, Throwable|null $previous = null)
{
parent::__construct(
sprintf(
'snapshot for aggregate "%s" with the id "%s" not found',
$aggregate,
$id->toString(),
$aggregateRootClass,
$rootId->toString(),
),
0,
$previous,
Expand Down

0 comments on commit 33e5b56

Please sign in to comment.