可借用的 / 汇总
可借用的汇总库
1.1.3
2024-05-01 10:35 UTC
Requires
- php: ^8.2
- beberlei/assert: ^3.3
- ramsey/uuid: ^4.5
Requires (Dev)
- ergebnis/composer-normalize: ^2.42.0
- lendable/composer-license-checker: ^1.2.0
- php-cs-fixer/shim: ^3.54.0
- php-parallel-lint/php-parallel-lint: ^1.4.0
- phpstan/phpstan: ^1.10.67
- phpstan/phpstan-deprecation-rules: ^1.1.4
- phpstan/phpstan-phpunit: ^1.3.16
- phpstan/phpstan-strict-rules: ^1.5.5
- phpunit/phpunit: ^11.1.3
- qossmic/deptrac: ^2.0.0-alpha
- rector/rector: ^1.0.4
- dev-main
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.0
- 0.4.0
- 0.3.0
- 0.2.1
- 0.2.0
- 0.1.0
- dev-renovate/lock-file-maintenance
- dev-gh-readonly-queue/main/pr-774-928fe41dab3852aee0fd846b915ac2befcdf0922
- dev-renovate/composer-dev
- dev-gh-readonly-queue/main/pr-773-e44220dadbab38a090d149cb42c627b64c905c2e
- dev-gh-readonly-queue/main/pr-772-63a007bb7d37fddbf929251b0b378ef2bddf7f2c
- dev-gh-readonly-queue/main/pr-742-cab42d3e0a12da00b88691401386bcabf3714ba0
- dev-php8
This package is auto-updated.
Last update: 2024-09-21 06:46:28 UTC
README
支持在事件源系统中汇总交互的领域和基础设施的库。
这不会帮助您构建领域。相反,它为基础设施层提供接口和基本功能,以便与您的汇总类进行交互,而无需它们实现特定于库的接口。
安装
您可以通过Composer安装此库。
composer require lendable/aggregate
需求
- PHP >= 8.2
功能
AggregateIdExtractor
定义从领域汇总对象中提取 AggregateId
的契约。您的汇总类不应持有 AggregateId
实例,而应使用特定于领域的标识类型(例如,UserId
)。
AggregateTypeResolver
定义从领域汇总对象中解析 AggregateType
的契约。AggregateType
是汇总的分类。这是一个基础设施问题,旨在与 AggregateId
一起进行审计日志记录,以及单架构/多汇总存储模式。
AggregateVersionExtractor
定义从领域汇总对象中提取 AggregateVersion
的契约。这是一个事件源基础设施概念,其中(通常)版本随着对汇总状态有影响的每个事件的增加而增加。
测试支持
提供了 AggregateIdExtractorSpec
、AggregateTypeResolverSpec
和 AggregateVersionExtractorSpec
以简化您实现测试。只需扩展这些类以用于您自己的测试套件,并实现钩子点。
use Lendable\Aggregate\Testing\AggregateIdExtractorSpec; use Lendable\Aggregate\AggregateIdExtractor; use Lendable\Aggregate\AggregateId; final class FooIdExtractor extends AggregateIdExtractorSpec { protected function createExtractor(): AggregateIdExtractor { return new FooIdExtractor(); } protected function createExpectedAggregateId(): AggregateId { return AggregateId::fromString('1406fd13-29d3-44e3-812c-c1cd14e12b38'); } protected function createAggregateWithExpectedAggregateId(): object { return Foo::register(FooId::fromString('1406fd13-29d3-44e3-812c-c1cd14e12b38')); } }