complex-heart / domain-model
Domain model toolset to properly build Value Objects, Entities and Aggregates.
v4.2.0
2024-07-17 23:48 UTC
Requires
- php: ^8.1.0
- ext-json: *
- complex-heart/contracts: ^2.0.0
- doctrine/instantiator: ^2.0.0
- illuminate/collections: ^11.0.0
- lambdish/phunctional: ^2.1.0
- nesbot/carbon: ^3.2.0
- ramsey/uuid: ^4.1.0
Requires (Dev)
- mockery/mockery: ^1.6.0
- pestphp/pest: ^2.0
- pestphp/pest-plugin-faker: ^2.0
- phpstan/extension-installer: ^1.3
- phpstan/phpstan: ^1.0
- phpstan/phpstan-mockery: ^1.1
README
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 byHasAttributes
andHasInvariants
.IsValueObject
composed byIsModel
andHasEquality
.IsEntity
composed byIsModel
,HasIdentity
,HasEquality
.IsAggregate
composed byIsEntity
,HasDomainEvents
.
For more information please check the wiki.