Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ phpunit-integration: vendor

.PHONY: phpunit-integration-postgres
phpunit-integration-postgres: vendor ## run phpunit integration tests on postgres
DB_URL="pdo-pgsql://postgres:postgres@localhost:5432/eventstore?charset=utf8" vendor/bin/phpunit --testsuite=integration
DB_URL="pdo-pgsql://postgres:postgres@127.0.0.1:5432/eventstore?charset=utf8" vendor/bin/phpunit --testsuite=integration

.PHONY: phpunit-integration-mysql
phpunit-integration-mysql: vendor ## run phpunit integration tests on mysql
DB_URL="pdo-mysql://root@localhost:3306/eventstore?charset=utf8" vendor/bin/phpunit --testsuite=integration
DB_URL="pdo-mysql://root@127.0.0.1:3306/eventstore?charset=utf8" vendor/bin/phpunit --testsuite=integration

.PHONY: phpunit-unit
phpunit-unit: vendor ## run phpunit unit tests
Expand Down
2 changes: 2 additions & 0 deletions src/Metadata/Message/MessageHeaderRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Patchlevel\EventSourcing\Store\Header\PlayheadHeader;
use Patchlevel\EventSourcing\Store\Header\RecordedOnHeader;
use Patchlevel\EventSourcing\Store\Header\StreamNameHeader;
use Patchlevel\EventSourcing\Store\Header\TagsHeader;
use Patchlevel\EventSourcing\Store\StreamStartHeader;

use function array_flip;
Expand Down Expand Up @@ -85,6 +86,7 @@ public static function createWithInternalHeaders(array $headerNameToClassMap = [
'newStreamStart' => StreamStartHeader::class,
'eventId' => EventIdHeader::class,
'index' => IndexHeader::class,
'tags' => TagsHeader::class,
];

return new self($headerNameToClassMap + $internalHeaders);
Expand Down
26 changes: 26 additions & 0 deletions src/Store/Criteria/TagCriterion.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace Patchlevel\EventSourcing\Store\Criteria;

use InvalidArgumentException;

use function array_unique;
use function array_values;

final class TagCriterion
{
/** @var list<string> */
public readonly array $tags;

public function __construct(
string ...$tags,
) {
$this->tags = array_values(array_unique($tags));

if ($this->tags === []) {
throw new InvalidArgumentException('At least one tag must be provided.');
}
}
}
15 changes: 15 additions & 0 deletions src/Store/Header/TagsHeader.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

namespace Patchlevel\EventSourcing\Store\Header;

/** @psalm-immutable */
class TagsHeader

Check failure on line 8 in src/Store/Header/TagsHeader.php

View workflow job for this annotation

GitHub Actions / Static Analysis by PHPStan (locked, 8.3, ubuntu-latest)

Patchlevel\EventSourcing\Store\Header\TagsHeader should be final

Check failure on line 8 in src/Store/Header/TagsHeader.php

View workflow job for this annotation

GitHub Actions / Static Analysis by Psalm (locked, 8.3, ubuntu-latest)

ClassMustBeFinal

src/Store/Header/TagsHeader.php:8:7: ClassMustBeFinal: Class Patchlevel\EventSourcing\Store\Header\TagsHeader is never extended and is not part of the public API, and thus must be made final. (see https://psalm.dev/361)
{
/** @param list<string> $tags */
public function __construct(
public readonly array $tags,
) {
}
}
Loading
Loading