Skip to content

Commit

Permalink
rename projection attribute into projector
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidBadura committed Jan 3, 2024
1 parent 17589eb commit 2d46c17
Show file tree
Hide file tree
Showing 15 changed files with 47 additions and 47 deletions.
4 changes: 2 additions & 2 deletions docs/pages/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ use Doctrine\DBAL\Connection;
use Patchlevel\EventSourcing\Attribute\Create;
use Patchlevel\EventSourcing\Attribute\Drop;
use Patchlevel\EventSourcing\Attribute\Subscribe;
use Patchlevel\EventSourcing\Attribute\Projection;
use Patchlevel\EventSourcing\Attribute\Projector;
use Patchlevel\EventSourcing\EventBus\Message;
use Patchlevel\EventSourcing\Projection\Projection\ProjectionId;
use Patchlevel\EventSourcing\Projection\Projector\ProjectorUtil;

#[Projection('hotel')]
#[Projector('hotel')]
final class HotelProjector
{
use ProjectorUtil;
Expand Down
18 changes: 9 additions & 9 deletions docs/pages/projection.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ use Doctrine\DBAL\Connection;
use Patchlevel\EventSourcing\Attribute\Create;
use Patchlevel\EventSourcing\Attribute\Drop;
use Patchlevel\EventSourcing\Attribute\Subscribe;
use Patchlevel\EventSourcing\Attribute\Projection;
use Patchlevel\EventSourcing\Attribute\Projector;
use Patchlevel\EventSourcing\EventBus\Message;
use Patchlevel\EventSourcing\Projection\Projector\ProjectorUtil;

#[Projection('profile')]
#[Projector('profile')]
final class ProfileProjector
{
use ProjectorUtil;
Expand Down Expand Up @@ -81,7 +81,7 @@ final class ProfileProjector

Each projector is responsible for a specific projection and version.
This combination of information results in the so-called `project ID`.
In order for us to be able to define this, we have to use the `Projection` attribute.
In order for us to be able to define this, we have to use the `Projector` attribute.
In our example, the projection is called "profile" and has the version "0" because we did not specify it.
So that there is no problems with existing projection,
both the name of the projection and the version should be part of the table/collection name.
Expand Down Expand Up @@ -114,17 +114,17 @@ Several projectors can also listen to the same event.

As soon as the structure of a projection changes, the version must be change or increment.
Otherwise the projectionist will not recognize that the projection has changed and will not rebuild it.
To do this, you have to change the version in the `Projection` attribute.
To do this, you have to change the version in the `Projector` attribute.

```php
use Doctrine\DBAL\Connection;
use Patchlevel\EventSourcing\Attribute\Create;
use Patchlevel\EventSourcing\Attribute\Drop;
use Patchlevel\EventSourcing\Attribute\Handle;
use Patchlevel\EventSourcing\Attribute\Projection;
use Patchlevel\EventSourcing\Attribute\Projector;
use Patchlevel\EventSourcing\EventBus\Message;

#[Projection('profile', version: 1)]
#[Projector('profile', version: 1)]
final class ProfileProjector
{
// ...
Expand Down Expand Up @@ -169,12 +169,12 @@ If something breaks, the projectionist marks the individual projections as fault
## Projection Id

A projection id consists of a unique name and a version.
It can be defined using the `Projection` attribute.
It can be defined using the `Projector` attribute.

```php
use Patchlevel\EventSourcing\Attribute\Projection;
use Patchlevel\EventSourcing\Attribute\Projector;

#[Projection('profile', version: 1)]
#[Projector('profile', version: 1)]
final class ProfileProjector
{
// ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Attribute;

#[Attribute(Attribute::TARGET_CLASS)]
final class Projection
final class Projector
{
public function __construct(
private string $name,
Expand Down
4 changes: 2 additions & 2 deletions src/Metadata/Projector/AttributeProjectorMetadataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Patchlevel\EventSourcing\Attribute\Create;
use Patchlevel\EventSourcing\Attribute\Drop;
use Patchlevel\EventSourcing\Attribute\Projection;
use Patchlevel\EventSourcing\Attribute\Projector;
use Patchlevel\EventSourcing\Attribute\Subscribe;
use ReflectionClass;

Expand All @@ -26,7 +26,7 @@ public function metadata(string $projector): ProjectorMetadata

$reflector = new ReflectionClass($projector);

$attributes = $reflector->getAttributes(Projection::class);
$attributes = $reflector->getAttributes(Projector::class);

if ($attributes === []) {
throw new ClassIsNotAProjector($projector);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
use Doctrine\DBAL\Connection;
use Patchlevel\EventSourcing\Attribute\Create;
use Patchlevel\EventSourcing\Attribute\Drop;
use Patchlevel\EventSourcing\Attribute\Projection;
use Patchlevel\EventSourcing\Attribute\Projector;
use Patchlevel\EventSourcing\Attribute\Subscribe;
use Patchlevel\EventSourcing\EventBus\Message;
use Patchlevel\EventSourcing\Tests\Benchmark\BasicImplementation\Events\ProfileCreated;

use function assert;

#[Projection('dummy', 1)]
#[Projector('dummy', 1)]
final class ProfileProjector
{
public function __construct(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
use Doctrine\DBAL\Schema\Table;
use Patchlevel\EventSourcing\Attribute\Create;
use Patchlevel\EventSourcing\Attribute\Drop;
use Patchlevel\EventSourcing\Attribute\Projection;
use Patchlevel\EventSourcing\Attribute\Projector;
use Patchlevel\EventSourcing\Attribute\Subscribe;
use Patchlevel\EventSourcing\EventBus\Message;
use Patchlevel\EventSourcing\Tests\Integration\BankAccountSplitStream\Events\BalanceAdded;
use Patchlevel\EventSourcing\Tests\Integration\BankAccountSplitStream\Events\BankAccountCreated;

#[Projection('dummy', 1)]
#[Projector('dummy', 1)]
final class BankAccountProjection
{
public function __construct(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
use Doctrine\DBAL\Schema\Table;
use Patchlevel\EventSourcing\Attribute\Create;
use Patchlevel\EventSourcing\Attribute\Drop;
use Patchlevel\EventSourcing\Attribute\Projection;
use Patchlevel\EventSourcing\Attribute\Projector;
use Patchlevel\EventSourcing\Attribute\Subscribe;
use Patchlevel\EventSourcing\EventBus\Message;
use Patchlevel\EventSourcing\Tests\Integration\BasicImplementation\Events\ProfileCreated;

use function assert;

#[Projection('profile', 1)]
#[Projector('profile', 1)]
final class ProfileProjection
{
public function __construct(
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/Outbox/Projection/ProfileProjection.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
use Doctrine\DBAL\Schema\Table;
use Patchlevel\EventSourcing\Attribute\Create;
use Patchlevel\EventSourcing\Attribute\Drop;
use Patchlevel\EventSourcing\Attribute\Projection;
use Patchlevel\EventSourcing\Attribute\Projector;
use Patchlevel\EventSourcing\Attribute\Subscribe;
use Patchlevel\EventSourcing\EventBus\Message;
use Patchlevel\EventSourcing\Tests\Integration\Outbox\Events\ProfileCreated;

#[Projection('dummy', 1)]
#[Projector('dummy', 1)]
final class ProfileProjection
{
public function __construct(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Doctrine\DBAL\Schema\Table;
use Patchlevel\EventSourcing\Attribute\Create;
use Patchlevel\EventSourcing\Attribute\Drop;
use Patchlevel\EventSourcing\Attribute\Projection;
use Patchlevel\EventSourcing\Attribute\Projector;
use Patchlevel\EventSourcing\Attribute\Subscribe;
use Patchlevel\EventSourcing\EventBus\Message;
use Patchlevel\EventSourcing\Projection\Projector\ProjectorUtil;
Expand All @@ -17,7 +17,7 @@
use function assert;
use function sprintf;

#[Projection('profile', 1)]
#[Projector('profile', 1)]
final class ProfileProjection
{
use ProjectorUtil;
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Fixture/Dummy2Projection.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

use Patchlevel\EventSourcing\Attribute\Create;
use Patchlevel\EventSourcing\Attribute\Drop;
use Patchlevel\EventSourcing\Attribute\Projection;
use Patchlevel\EventSourcing\Attribute\Projector;
use Patchlevel\EventSourcing\Attribute\Subscribe;
use Patchlevel\EventSourcing\EventBus\Message as EventMessage;
use Patchlevel\EventSourcing\Projection\Projection\ProjectionId;

#[Projection('dummy2', 1)]
#[Projector('dummy2', 1)]
final class Dummy2Projection
{
public EventMessage|null $handledMessage = null;
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Fixture/DummyProjection.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

use Patchlevel\EventSourcing\Attribute\Create;
use Patchlevel\EventSourcing\Attribute\Drop;
use Patchlevel\EventSourcing\Attribute\Projection;
use Patchlevel\EventSourcing\Attribute\Projector;
use Patchlevel\EventSourcing\Attribute\Subscribe;
use Patchlevel\EventSourcing\EventBus\Message as EventMessage;
use Patchlevel\EventSourcing\Projection\Projection\ProjectionId;

#[Projection('dummy', 1)]
#[Projector('dummy', 1)]
final class DummyProjection
{
public EventMessage|null $handledMessage = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Patchlevel\EventSourcing\Attribute\Create;
use Patchlevel\EventSourcing\Attribute\Drop;
use Patchlevel\EventSourcing\Attribute\Projection;
use Patchlevel\EventSourcing\Attribute\Projector;
use Patchlevel\EventSourcing\Attribute\Subscribe;
use Patchlevel\EventSourcing\Metadata\Projector\AttributeProjectorMetadataFactory;
use Patchlevel\EventSourcing\Metadata\Projector\ClassIsNotAProjector;
Expand All @@ -31,7 +31,7 @@ public function testNotAProjection(): void

public function testEmptyProjection(): void
{
$projection = new #[Projection('foo', 1)]
$projection = new #[Projector('foo', 1)]
class {
};

Expand All @@ -47,7 +47,7 @@ class {

public function testStandardProjection(): void
{
$projection = new #[Projection('foo', 1)]
$projection = new #[Projector('foo', 1)]
class {
#[Subscribe(ProfileVisited::class)]
public function handle(): void
Expand Down Expand Up @@ -79,7 +79,7 @@ public function drop(): void

public function testMultipleHandlerOnOneMethod(): void
{
$projection = new #[Projection('foo', 1)]
$projection = new #[Projector('foo', 1)]
class {
#[Subscribe(ProfileVisited::class)]
#[Subscribe(ProfileCreated::class)]
Expand All @@ -104,7 +104,7 @@ public function testDuplicateCreateAttributeException(): void
{
$this->expectException(DuplicateCreateMethod::class);

$projection = new #[Projection('foo', 1)]
$projection = new #[Projector('foo', 1)]
class {
#[Create]
public function create1(): void
Expand All @@ -125,7 +125,7 @@ public function testDuplicateDropAttributeException(): void
{
$this->expectException(DuplicateDropMethod::class);

$projection = new #[Projection('foo', 1)]
$projection = new #[Projector('foo', 1)]
class {
#[Drop]
public function drop1(): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Patchlevel\EventSourcing\Tests\Unit\Projection\Projectionist;

use Patchlevel\EventSourcing\Attribute\Projection as ProjectionAttribute;
use Patchlevel\EventSourcing\Attribute\Projector as ProjectionAttribute;
use Patchlevel\EventSourcing\EventBus\Message;
use Patchlevel\EventSourcing\Projection\Projection\Projection;
use Patchlevel\EventSourcing\Projection\Projection\ProjectionCollection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Patchlevel\EventSourcing\Attribute\Create;
use Patchlevel\EventSourcing\Attribute\Drop;
use Patchlevel\EventSourcing\Attribute\Projection;
use Patchlevel\EventSourcing\Attribute\Projector;
use Patchlevel\EventSourcing\Attribute\Subscribe;
use Patchlevel\EventSourcing\EventBus\Message;
use Patchlevel\EventSourcing\Projection\Projector\MetadataProjectorResolver;
Expand All @@ -21,7 +21,7 @@ final class MetadataProjectorResolverTest extends TestCase
{
public function testResolveHandleMethod(): void
{
$projection = new #[Projection('dummy')]
$projection = new #[Projector('dummy')]
class {
public static Message|null $handledMessage = null;

Expand Down Expand Up @@ -51,7 +51,7 @@ public function handleProfileCreated(Message $message): void

public function testNotResolveHandleMethod(): void
{
$projection = new #[Projection('dummy')]
$projection = new #[Projector('dummy')]
class {
};

Expand All @@ -69,7 +69,7 @@ class {

public function testResolveCreateMethod(): void
{
$projection = new #[Projection('dummy')]
$projection = new #[Projector('dummy')]
class {
public static bool $called = false;

Expand All @@ -92,7 +92,7 @@ public function method(): void

public function testNotResolveCreateMethod(): void
{
$projection = new #[Projection('dummy')]
$projection = new #[Projector('dummy')]
class {
};

Expand All @@ -104,7 +104,7 @@ class {

public function testResolveDropMethod(): void
{
$projection = new #[Projection('dummy')]
$projection = new #[Projector('dummy')]
class {
public static bool $called = false;

Expand All @@ -127,7 +127,7 @@ public function method(): void

public function testNotResolveDropMethod(): void
{
$projection = new #[Projection('dummy')]
$projection = new #[Projector('dummy')]
class {
};

Expand All @@ -139,7 +139,7 @@ class {

public function testProjectionId(): void
{
$projection = new #[Projection('dummy', 1)]
$projection = new #[Projector('dummy', 1)]
class {
};

Expand Down
8 changes: 4 additions & 4 deletions tests/Unit/Projection/Projector/ProjectorHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Patchlevel\EventSourcing\Tests\Unit\Projection\Projector;

use Patchlevel\EventSourcing\Attribute\Projection;
use Patchlevel\EventSourcing\Attribute\Projector;
use Patchlevel\EventSourcing\Projection\Projection\ProjectionId;
use Patchlevel\EventSourcing\Projection\Projector\ProjectorHelper;
use PHPUnit\Framework\TestCase;
Expand All @@ -14,7 +14,7 @@ final class ProjectorHelperTest extends TestCase
{
public function testProjectionName(): void
{
$projector = new #[Projection('dummy')]
$projector = new #[Projector('dummy')]
class {
};

Expand All @@ -25,7 +25,7 @@ class {

public function testProjectionVersion(): void
{
$projector = new #[Projection('dummy', 1)]
$projector = new #[Projector('dummy', 1)]
class {
};

Expand All @@ -36,7 +36,7 @@ class {

public function testProjectionId(): void
{
$projector = new #[Projection('dummy', 1)]
$projector = new #[Projector('dummy', 1)]
class {
};

Expand Down

0 comments on commit 2d46c17

Please sign in to comment.