Skip to content
CAI
Software that uses CAICheck a score

ericksonreyes/domain-driven-design

46.6

Weak · 9 November 2026

2.9k

lines of production code

PHP

primary language

7

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

This system is a PHP library implementing Domain-Driven Design (DDD) patterns, providing a structured foundation for building robust applications. It offers a complete set of domain primitives, including value objects for money, addresses, and person identities, alongside interfaces for command and event buses. The library also supports event sourcing and file attachment capabilities for domain entities, all backed by comprehensive automated testing and continuous integration infrastructure.

How it got here

2019 — Initial DDD library scaffolding

13 changes.

This period established the foundational structure of a Domain-Driven Design library, implementing core components such as the Command/Event Bus, value objects, and event-sourced entities. The work included setting up the CI/CD infrastructure and writing comprehensive unit tests to ensure the reliability of these new domain primitives.

2020 — Domain object and exception infrastructure

7 changes.

This period focused on establishing the foundational value objects for Person and Address, along with their corresponding unit tests. The work also introduced a comprehensive set of domain-specific exception classes to handle validation and business rule failures across the domain layer.

Features

Add Person value objects with full-name comparison

The Person value object area now includes new classes for Title, Name, Suffix, and FullName, enabling the construction of a complete person identity. The FullName class aggregates these components and provides a matches() method to compare two full names for equality, as well as a doesNotMatch() method for inequality checks. Corresponding exception classes (e.g., EmptyTitleError, EmptyNameError) are added to handle validation errors.

src/EricksonReyes/DomainDrivenDesign/Common/ValueObject/Person · high confidence

Add domain-specific error classes for common failure scenarios

The codebase introduces a new set of abstract and final exception classes under the DomainDrivenDesign namespace, including AuthenticationFailureError, DeletedRecordError, DomainEventOwnershipError, EmptyIdentifierError, MissingActionPerformerError, MissingEventReplayMethodError, PermissionDeniedError, RecordConflictError, RecordNotFoundError, and TooManyRequestsError. These classes extend standard PHP exceptions (such as InvalidArgumentException, BadMethodCallException, and Exception) to provide domain-expert-friendly error handling for specific business rules and system states.

src/EricksonReyes/DomainDrivenDesign/Common/Exception · high confidence

Add new domain value objects for Money, File, and Phone

Introduced several new value objects to the Domain-Driven Design common library: a Money object that handles currency-typed amounts with comparison and addition capabilities; a File object that manages file metadata, content, and size comparisons; and a PhoneNumber object that validates and stores country, area, and local number components. These additions expand the shared domain primitives available for building domain models.

src/EricksonReyes/DomainDrivenDesign/Common/ValueObject · high confidence

Added CommandBus and EventBus implementations with dedicated exception classes

The application layer now includes a new CommandBus and EventBus, each with their own set of exception classes (DuplicateCommandHandlerError, DuplicateEventHandlerError, MissingHandlerMethodError, UnhandledCommandError). The CommandBus manages command handlers and dispatches commands, while the EventBus registers event handlers and dispatches events, including exception handling for failed event notifications.

src/EricksonReyes/DomainDrivenDesign/Application · high confidence

Added composition-aware validation helpers

The validation namespace now includes a new ClassExtractor utility and a ComposedClass wrapper. ClassExtractor provides static methods to recursively search through object compositions to find or verify the presence of specific class types. ComposedClass wraps an object and exposes has, doesntHave, and extract methods that delegate to the extractor, allowing users to easily check or retrieve nested components within a composed structure.

src/EricksonReyes/DomainDrivenDesign/Common/Validation · high confidence

Added infrastructure interfaces for command/event handling and identity generation

The project now includes a set of new infrastructure interfaces to support domain-driven design patterns. This includes a generic Collection class for managing item sets, and interfaces for a CommandBus and EventBus to handle application commands and domain events respectively. Additional interfaces for event handling (EventHandler, ExceptionHandler), event persistence (EventRepository, EventStore), and identity generation (IdentityGenerator) have been introduced to structure the application's core logic.

src/EricksonReyes/DomainDrivenDesign/Infrastructure · medium confidence

Adds domain entity and event-sourced entity examples

The example directory now includes new domain models: a basic \DomainEntity\ with identity and matching logic, an \EventSourcedDomainEntity\ that handles deletion via an event, and a \FileAttachingDomainEntity\ that incorporates file-attaching capabilities. These classes demonstrate how to implement domain entities and event sourcing patterns within the library.

src/EricksonReyes/DomainDrivenDesign/Example · high confidence

Initial project scaffolding and CI configuration

The repository was initialized with a complete build and testing infrastructure. This includes Phing build scripts (build.xml, build.ci.xml, build.local.xml) for code quality checks (PHPCS, PHPMD, PHPCPD) and unit testing (PhpSpec, PHPUnit). Configuration files for Travis CI (.travis.yml) and Coveralls (.coveralls.yml) were added to automate continuous integration and code coverage reporting. Additionally, a PHP wrapper script (php) and various configuration files (phpcs.xml, phpmd.xml, phpspec.\*.yml, phpunit.xml) were introduced to support the development workflow.

(repo-wide) · high confidence

Introduce Address value object with comparison capabilities

A new Address value object has been added to the domain, composed of Street, City, State, CountryCode, and ZipCode components. Each component enforces non-empty validation via dedicated error classes, and the Address class provides a matches() method to compare two address instances for equality across all fields.

src/EricksonReyes/DomainDrivenDesign/Common/ValueObject/Address · high confidence

New common interfaces for domain objects

Added a set of new interfaces in the Domain-Driven Design common layer to standardize how domain objects expose their properties and behaviors. These include \CanBeValidated\, \CanCompareAmount\, \CanCompareLength\, \CanCompareSize\, \CanDetermineIfEmpty\, \CanMatchString\, \HasAmount\, \HasArrayRepresentation\, \HasComposition\, \HasLength\, and \HasSize\. An abstract base class \SizeableAndMatchableString\ was also introduced to provide default implementations for string comparison and matching logic.

src/EricksonReyes/DomainDrivenDesign/Common/Interfaces · high confidence

New domain interfaces and traits for event sourcing and file attachments

The domain layer now includes new interfaces and traits to support event sourcing and file attachments. The \Event\ interface defines the contract for domain events, while the \AccountableEvent\ interface extends it to track which entity raised an event. A new \Entity\ interface standardizes entity identity and comparison. For event sourcing, the \EventSourcedEntity\ class and its \EventSourcedEntityTrait\ provide methods to store, replay, and check the occurrence of domain events, including validation that an event belongs to the correct entity. Additionally, the \FileAttachingEntity\ class and its \FileAttachingEntityTrait\ enable entities to attach, detach, and retrieve files. A \History\ class extends \Collection\ to record events, and a \Repository\ interface is introduced for entity persistence.

src/EricksonReyes/DomainDrivenDesign/Domain · high confidence

Behavioural changes

Add domain-specific exception classes for value objects

The codebase now includes a set of new exception classes in the \EricksonReyes\\DomainDrivenDesign\\Common\\ValueObject\\Exception\ namespace, each extending \InvalidArgumentException\. These include \EmptyIdentifierError\, \InsufficientMoneyAmountError\, \InvalidCurrencyCodeError\, \InvalidEmailAddressError\, \InvalidMoneyAmountError\, \MismatchedCurrenciesError\, \MissingFileNameError\, \MissingFileTypeError\, \NegativeAreaCodeError\, \NegativeCountryCodeError\, \NegativeExtensionNumberError\, and \NegativePhoneNumberError\. These changes allow the application to throw specific, domain-friendly errors for various validation failures.

src/EricksonReyes/DomainDrivenDesign/Common/ValueObject/Exception · high confidence

Test coverage

Added test coverage for CommandBus and EventBus implementations; Added test coverage for Person value objects; Added tests for the ComposedClass validation logic; Added unit tests for Address value objects; Added unit tests for Domain classes; Added unit tests for domain entities and events; Added unit tests for domain value objects.

Dependencies

Initial composer.json for Domain Driven Design library

The project now includes a composer.json file that defines the PHP 7.2+ requirement and lists development dependencies for testing (PHPUnit, PHPSpec), code coverage, and static analysis tools (PHPCS, PHPMD, etc.).

(dependencies) · high confidence

Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Score

  • CAI 46 → 47 (+0.4)
  • Rubric changed (rubric-2026.10.5 → rubric-2026.11.2) — scores are not directly comparable.

Lenses

  • Code Health 71 → 71 (+0.0)
  • Architecture 98 → 98 (+0.0)
  • Maturity 30 → 30 (+0.8)
  • Readiness 38 → 38 (+0.0)
  • Security 100 → 100 (+0.0)
  • Domain Modelling 83 → 83 (+0.0)

Resolved (6)

  • Duplicate intent across concrete class and interface. 'SizeableAndMatchableString' implements 'HasLength' and 'CanCompareLength', but also defines its own length comparison methods directly. This duplicates the interface contract in the concrete class signature, creating redundancy.
  • Grammatical error and inconsistency in comparison method names. 'amountIsEqualsTo' is grammatically incorrect (should be 'amountIsEqualTo'). Furthermore, the interface 'CanCompareAmount' uses 'amountIsEqualsTo' while the concrete 'Money' class uses 'isEqualsTo' for object comparison, creating two different naming conventions for similar operations.
  • Inconsistent method naming for event handling lifecycle. The interface uses 'isInterestedInThis' and 'beNotifiedAbout', which are verbose and grammatically inconsistent ('is' vs 'be'). Mock implementations duplicate this inconsistency.
  • Inconsistent naming for containment checks. 'ComposedClass' uses 'has'/'doesntHave' (with a typo 'doesnt' instead of 'doesNot'), while 'ClassExtractor' uses 'contains'. These perform similar logical checks on composition.
  • Inconsistent verb usage for registering handlers. CommandBus uses 'addHandler', while EventBus uses 'register' for both event handlers and exception handlers. This creates confusion about whether 'add' or 'register' is the standard term for binding a handler to a bus.
  • Redundant/Inverse methods. 'eventNeverHappened' is logically the inverse of 'eventAlreadyHappened'. Exposing both increases API surface without adding distinct functionality, potentially leading to confusion about which to use.

Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

ericksonreyes/domain-driven-design was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 9 November 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 9fc5893fbf42aac08da54b669920d64e958d591c — the exact code this score is about.
  • Scored under rubric-2026.11.2 — the same rubric and the same method as every other entry in this index.
  • Measured by Canine Code Analyzer (cca.canine.dev) using cca measure-2026.11.3+preprod-bb0cb800cd0f.