PHP Classes

Complex Heart PHP Domain Driven Design Model: Value objects, entities and aggregates with traits

Recommend this page to a friend!
  Info   View files Documentation   View files View files (51)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Last Updated Ratings Unique User Downloads Download Rankings
2024-01-30 (2 months ago) RSS 2.0 feedNot enough user ratingsTotal: 57 This week: 3All time: 10,517 This week: 30Up
Version License PHP version Categories
ch-domain-model 1.0Custom (specified...8.1Data types, Design Patterns, PHP 8
Description 

Author

This package allows the implementation of value objects, entities, and aggregates using traits.

It provides classes and traits to implement domain-driven, design-based applications.

Currently, it also provides a set of traits that can be used to define the classes:

- HasAttributes

- HasDomainEvents

- HasEquality

- HasIdentity

- HasImmutability

- HasInvariants

- HasTypeCheck

It also provides classes to implement common types of value objects that use the traits above:

- ArrayValue

- BooleanValue

- EnumValue

- FloatValue

- IntegerValue

- StringValue

- UUIDValue

Innovation Award
PHP Programming Innovation award winner
February 2024
Winner
Domain-driven design is a software design approach that aims to match the domain of the problems that the applications should solve based on the input of the experts who understand the domain of the issues.

For instance, if a software project aims to solve e-commerce problems using domain-driven design, developers should model the implementation of the product using the experience of the e-commerce experts.

This package helps implement projects that use the domain-driven design to develop value objects, entities, and aggregates using value object classes and traits provided within this package.

Manuel Lemos
Picture of Unay Santisteban
  Performance   Level  
Name: Unay Santisteban <contact>
Classes: 7 packages by
Country: Spain Spain
Innovation award
Innovation award
Nominee: 3x

Winner: 1x

Documentation

Domain Model

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`.

For more information please check the wiki.


  Files folder image Files  
File Role Description
Files folder image.github (1 file, 2 directories)
Files folder imagesrc (5 files, 4 directories)
Files folder imagetests (5 files, 1 directory)
Files folder imagewiki (3 files)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Plain text file sonar-project.properties Data Auxiliary data

  Files folder image Files  /  .github  
File Role Description
Files folder imageISSUE_TEMPLATE (2 files)
Files folder imageworkflows (2 files)
  Accessible without login Plain text file CODEOWNERS Data Auxiliary data

  Files folder image Files  /  .github  /  ISSUE_TEMPLATE  
File Role Description
  Accessible without login Plain text file bug_report.md Data Auxiliary data
  Accessible without login Plain text file feature_request.md Data Auxiliary data

  Files folder image Files  /  .github  /  workflows  
File Role Description
  Accessible without login Plain text file documentation.yml Data Auxiliary data
  Accessible without login Plain text file test.yml Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
Files folder imageErrors (1 file)
Files folder imageExceptions (2 files)
Files folder imageTraits (7 files)
Files folder imageValueObjects (9 files)
  Plain text file IsAggregate.php Class Class source
  Plain text file IsEntity.php Class Class source
  Plain text file IsModel.php Class Class source
  Plain text file IsValueObject.php Class Class source
  Plain text file TypedCollection.php Class Class source

  Files folder image Files  /  src  /  Errors  
File Role Description
  Plain text file ImmutabilityError.php Class Class source

  Files folder image Files  /  src  /  Exceptions  
File Role Description
  Plain text file InstantiationException.php Class Class source
  Plain text file InvariantViolation.php Class Class source

  Files folder image Files  /  src  /  Traits  
File Role Description
  Plain text file HasAttributes.php Class Class source
  Plain text file HasDomainEvents.php Class Class source
  Plain text file HasEquality.php Class Class source
  Plain text file HasIdentity.php Class Class source
  Plain text file HasImmutability.php Class Class source
  Plain text file HasInvariants.php Class Class source
  Plain text file HasTypeCheck.php Class Class source

  Files folder image Files  /  src  /  ValueObjects  
File Role Description
  Plain text file ArrayValue.php Class Class source
  Plain text file BooleanValue.php Class Class source
  Plain text file DateTimeValue.php Class Class source
  Plain text file EnumValue.php Class Class source
  Plain text file FloatValue.php Class Class source
  Plain text file IntegerValue.php Class Class source
  Plain text file StringValue.php Class Class source
  Plain text file UUIDValue.php Class Class source
  Plain text file Value.php Class Class source

  Files folder image Files  /  tests  
File Role Description
Files folder imageOrderManagement (1 directory)
  Plain text file AggregatesTest.php Class Class source
  Accessible without login Plain text file Pest.php Aux. Auxiliary script
  Plain text file TraitsTest.php Class Class source
  Plain text file TypedCollectionTest.php Class Class source
  Plain text file ValueObjectsTest.php Class Class source

  Files folder image Files  /  tests  /  OrderManagement  
File Role Description
Files folder imageDomain (7 files, 2 directories)

  Files folder image Files  /  tests  /  OrderManagement  /  Domain  
File Role Description
Files folder imageErrors (1 file)
Files folder imageEvents (1 file)
  Plain text file Customer.php Class Class source
  Plain text file Order.php Class Class source
  Plain text file OrderLine.php Class Class source
  Plain text file OrderLines.php Class Class source
  Plain text file Price.php Class Class source
  Plain text file Reference.php Class Class source
  Plain text file Tags.php Class Class source

  Files folder image Files  /  tests  /  OrderManagement  /  Domain  /  Errors  
File Role Description
  Plain text file InvalidPriceError.php Class Class source

  Files folder image Files  /  tests  /  OrderManagement  /  Domain  /  Events  
File Role Description
  Plain text file OrderCreated.php Class Class source

  Files folder image Files  /  wiki  
File Role Description
  Accessible without login Plain text file Domain-Modeling-Aggregates.md Data Auxiliary data
  Accessible without login Plain text file Domain-Modeling-Entities.md Data Auxiliary data
  Accessible without login Plain text file Domain-Modeling-Value-Objects.md Data Auxiliary data

 Version Control Unique User Downloads Download Rankings  
 100%
Total:57
This week:3
All time:10,517
This week:30Up