定制 complex-heart/domain-model 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

complex-heart/domain-model

最新稳定版本:v5.0.0

Composer 安装命令:

composer require complex-heart/domain-model

包简介

Domain model toolset to properly build Value Objects, Entities and Aggregates.

README 文档

README

Tests Quality Gate Status Coverage

Modeling Aggregates, Entities and Value Objects

Complex Heart allows you to model your domain Aggregates, Entities, and Value Objects using a set of traits. Great, but why traits and not classes? Well, sometimes you have some kind of inheritance in your classes. Being forced to use a certain base class is too invasive and personally, I don't like it. By using a set of traits and interfaces you have all the functionality you need without compromising the essence of your own domain.

The available traits are:

  • HasAttributes Provide some functionality to manage attributes.
  • HasEquality Provide functionality to handle equality between objects.
  • HasInvariants Allow invariant checking on instantiation (Guard Clause).
  • HasIdentity Define the Entity/Aggregate identity.
  • HasDomainEvents Provide domain event management.

On top of those base traits Complex Heart provide ready to use compositions:

  • IsModel composed by HasAttributes and HasInvariants.
  • IsValueObject composed by IsModel and HasEquality.
  • IsEntity composed by IsModel, HasIdentity, HasEquality.
  • IsAggregate composed by IsEntity, HasDomainEvents.

Key Features

  • Type-Safe Factory Method: The make() static factory validates constructor parameters at runtime with clear error messages
  • Automatic Invariant Checking: When using make(), Value Objects and Entities automatically validate invariants after construction (no manual $this->check() needed)
  • Named Parameter Support: Full support for PHP 8.0+ named parameters for improved readability and flexibility
  • Union Type Support: Complete support for PHP 8.0+ union types (e.g., int|float, string|null)
  • Readonly Properties Support: Full compatibility with PHP 8.1+ readonly properties
  • PHPStan Level 8: Complete static analysis support

Note: Automatic invariant checking only works when using the make() factory method. Direct constructor calls require manual $this->check() in the constructor.

For more information and usage examples, please check the wiki.

统计信息

  • 总下载量: 2.14k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 0
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2021-06-15