somnambulist-tech/domain
66.4
Adequate · 21 September 2026
5k
lines of production code
PHP
primary language
4
measurements over time
What this system is
This system is a PHP component library providing domain-driven design primitives, including abstract base classes for entities, value objects, and aggregate roots. It implements a structured query bus for data retrieval and a robust event handling system that integrates with Doctrine and Symfony Messenger for asynchronous processing. The library also offers utility classes for identity generation, object comparison, and test assertions to streamline development and testing workflows.
How it got here
2019 — Domain model modernization
28 changes.
This period focused on a comprehensive architectural shift, removing legacy domain entities, value objects, and event handling mechanisms in favor of a modernized, component-based structure. The refactoring included migrating namespaces to Somnambulist\\Components, updating PHPUnit configurations, and introducing new query and utility abstractions to replace older patterns.
2020 — Event and job queue integration
12 changes.
This period focused on integrating the Symfony Messenger component to handle domain events, queries, and job queues. The work introduced new adapters, publishers, and behaviors to support automatic event dispatching, contextual data enrichment, and job processing within the library.
2022–2025 — Domain model and query response architecture
5 changes.
This period focused on establishing a structured domain-driven design foundation by introducing abstract base classes for entities, value objects, and aggregate roots. Concurrently, the codebase standardized query handling through new contract interfaces and specialized response types, supported by comprehensive test coverage for both domain models and query mechanisms.
Features
Add Doctrine helper traits for entity and query builder operations
The library introduces several new PHP traits to simplify common Doctrine operations. The EntityLocator namespace adds FindOrFail and Paginate traits, providing convenient methods to fetch entities by ID or criteria with exceptions on failure, and to paginate query results. The QueryBuilder namespace adds HasGroupByColumn, HasJoinAlias, and HasSelectColumn traits, which offer helper methods to inspect the state of a QueryBuilder instance (checking for specific columns in select/groupBy clauses or aliases in join clauses). These changes enhance the developer experience when working with Doctrine's ORM and DBAL components.
src/Doctrine/Behaviours · high confidence
Add event decorators to inject request ID and user data into events
Two new event decorators have been introduced to automatically enrich dispatched events with contextual data. The DecorateWithRequestId decorator injects the current HTTP request's unique identifier (from the 'X-Request-Id' header) into the event's context. The DecorateWithUserData decorator attaches the currently authenticated user's ID, name, and roles to the event's context, handling cases where no user is logged in. These decorators implement the EventDecoratorInterface and are designed to be used in the event dispatching pipeline.
src/Events/Decorators · high confidence
Added query contract interfaces for pagination, sorting, and response class
Three new interfaces have been introduced in the query contracts namespace: Paginatable (defining page and perPage methods), Sortable (defining an orderBy method returning a FrozenCollection), and UsesResponseClass (defining a responseClass method). These contracts establish the expected behavior for query components, enabling consistent handling of pagination, sorting, and response class resolution across the application.
src/Queries/Contracts · medium confidence
Introduce Messenger-based query bus adapter
A new MessengerQueryBus adapter has been added to the Queries/Adapters directory, implementing the QueryBus interface by delegating query execution to the Symfony Messenger component. This adapter supports both standard query execution and responses that require specific response classes, ensuring type safety and proper status handling for query results.
src/Queries/Adapters · high confidence
Introduce job queue abstraction and messenger adapter
The library now includes a new job queue abstraction defined by the \JobQueue\ interface and an implementation for the Symfony Messenger component (\MessengerJobQueue\). This change introduces a \Somnambulist\\Components\\Jobs\ namespace containing an \AbstractJob\ base class and the queue interface, enabling jobs to be dispatched via the Symfony Messenger bus.
src/Jobs · medium confidence
Introduce query behaviour traits for pagination, sorting, and metadata handling
Added new PHP 8.1-compatible traits in the \Somnambulist\\Components\\Queries\\Behaviours\ namespace to standardize query object capabilities. \CanPaginateQuery\ exposes page and per-page properties, \CanSortQuery\ provides an \orderBy\ collection (with a \CanOrderQuery\ alias), \CanIncludeRelatedData\ manages included sub-objects, \CanIncludeMetaData\ stores arbitrary metadata, and \CanUseResponseClass\ configures the response class. These traits enable consistent query construction and response handling across the library.
src/Queries/Behaviours · high confidence
Introduce structured query response types
Added a new set of classes in the Queries/Responses namespace to standardize how query results are returned. This includes an AbstractQueryResponse base class, a QueryResponseStatus value object for tracking success/failure states, and specific response types (ArrayQueryResponse, GenericQueryResponse, PaginatedQueryResponse, ReadModelQueryResponse) that encapsulate query data and status for different data shapes.
src/Queries/Responses · high confidence
Introduces new query base classes and QueryBus interface
The library now provides a structured query handling system with new abstract base classes: AbstractQuery, AbstractFindByIdQuery, and AbstractPaginatableQuery. The AbstractFindByIdQuery simplifies queries that retrieve entities by ID, while AbstractPaginatableQuery provides built-in support for pagination, sorting, and including related data or metadata via new behaviors. A new QueryBus interface is introduced to execute queries, replacing the previous direct invocation pattern with a more consistent and extensible execution model.
src/Queries · high confidence
New domain model base classes and types
Added new base classes for domain-driven design, including \AbstractEntity\, \AbstractEntityCollection\, \AbstractValueObject\, and \AggregateRoot\, along with supporting contracts, exceptions, and specific types like \Password\, \Country\, and \DateTime\ helpers. These provide a structured way to implement entities, value objects, and aggregate roots with built-in equality testing and event raising.
src/Models · high confidence
New event handling traits for decoration, gathering, and sorting
The codebase introduces three new traits in the event handling layer: CanDecorateEvents, which allows injecting contextual data into events before dispatch; CanGatherEventsForDispatch, which collects published domain events from aggregate roots; and CanSortEvents, which orders events by creation time. These traits provide a consistent, reusable way to manage event lifecycle stages within the Somnambulist Components library.
src/Events/Behaviours · high confidence
New event publisher implementations for Doctrine and Symfony Messenger
The library introduces three new classes in the \Somnambulist\\Components\\Events\\Publishers\ namespace: an abstract \AbstractEventPublisher\ base class, a \DoctrineEventPublisher\ that integrates with Doctrine's lifecycle events (prePersist, preRemove, preFlush, postFlush) to collect and dispatch domain events, and a \MessengerEventPublisher\ that extends the abstract class to support Symfony Messenger integration. These classes enable automatic event publishing from aggregate roots, with support for event decoration, sorting, and dispatch via the event bus.
src/Events/Publishers · high confidence
New event serialization and messaging adapters
Added DomainEventNormalizer to handle serialization and deserialization of domain events using Symfony's Serializer component, and introduced MessengerEventBus to dispatch events via Symfony Messenger with support for AMQP transport and delayed execution via DispatchAfterCurrentBusStamp.
src/Events/Adapters · high confidence
New identity and object diff utilities, plus EntityAccessor enhancements
Added IdentityGenerator for creating and hashing UUIDs, and ObjectDiff for deep comparison of object states. EntityAccessor now includes a has() method to check for property existence and an extract() method to recursively serialize object properties into an array, supporting nested objects and arrays.
src/Utils · high confidence
Removals
Removal of Doctrine-specific domain event publishing mechanism
The \DomainEventPublisher\ and \EventProxy\ classes, which previously handled the automatic capture and dispatch of domain events via Doctrine lifecycle hooks, have been removed. This eliminates the automatic event publishing tied to the Doctrine ORM, requiring users to adopt an alternative event bus or publisher implementation.
src/Events/Publishers/Doctrine · high confidence
Removed DateTime value objects and traits
The DateTime-related classes and traits have been removed from the codebase. Specifically, the \TimeZone\ entity and the \Comparable\, \Modifiers\, and \Stringable\ traits (which provided date comparison, date arithmetic, and string formatting methods) are no longer present.
src/Entities/Types/DateTime · high confidence
Removed Identity value object classes
The \Aggregate\ and \Uuid\ classes, previously located in the \Somnambulist\\Domain\\Entities\\Types\\Identity\ namespace, have been removed from the codebase. This eliminates the legacy identity value object implementations that previously handled aggregate identification and UUID validation.
src/Entities/Types/Identity · high confidence
Removed legacy entity base classes and unit enums
The abstract base classes AbstractValueObject and AggregateRoot, along with the AreaUnit and DistanceUnit enumeration classes, have been removed from the codebase. This change eliminates the legacy entity implementation and associated measurement unit definitions, likely as part of a broader refactoring to modernize the domain model.
src/Entities · high confidence
Behavioural changes
Add support for deferring command execution to the end of the current request
The command bus now supports a new 'afterCurrent' method that allows commands to be deferred and executed only after the current handler has finished without an exception. This is implemented via the 'DispatchAfterCurrentBusStamp' from Symfony Messenger, enabling developers to schedule commands to run at the end of the request cycle rather than immediately.
src/Commands · high confidence
Doctrine types restructured under new namespace with modernized error handling
All Doctrine type classes have been moved from the \Somnambulist\\Domain\\Doctrine\\Types\ namespace to \Somnambulist\\Components\\Doctrine\\Types\. This refactor includes adding new base classes \AbstractIdentityType\ and \AbstractValueObjectType\ to reduce duplication, introducing a new \PasswordType\, and updating all types to use \Doctrine\\DBAL\\Types\\Exception\\InvalidFormat\ or \ValueNotConvertible\ instead of the deprecated \ConversionException\. Additionally, the \EnumerationBridge\ has been restructured to remove the \name\ parameter from constructor/serializer callables, and the \Jsonb\ type has been removed.
src/Doctrine/Types · high confidence
Migrate Doctrine bootstrapping and add new DQL functions
The old \Somnambulist\\Domain\\Doctrine\\Bootstrapper\ has been removed and replaced with a new \Somnambulist\\Components\\Doctrine\\TypeBootstrapper\ that registers additional built-in types (password, email, identity, phone, url) and enumeration bridges. A new \AbstractAggregateRepository\ provides standard CRUD operations for aggregate roots. New DQL functions have been added: \CastToFunction\ for Postgres casting, \IlikeFunction\ for case-insensitive matching, \ReplaceFunction\ for string replacement, and \TypeFunction\ for accessing entity discriminators. A \Paginator\ helper wrapping Pagerfanta has also been introduced.
src/Doctrine · high confidence
Refactored Doctrine enumeration constructors and serializers with namespace updates
The enumeration handling in the Doctrine layer has been refactored to support typed enumerations and multitons with pre-casting for integer values. New constructors (Country, Currency, TypedEnumerable, TypedMultiton) replace the previous GenericEloquentEnumeration and specific enumerations, allowing the system to correctly cast database values to the appropriate PHP types. Additionally, the Country and Currency serializers have been updated to remove the explicit (string) cast, relying instead on the value objects' own string conversion, and all affected classes have been re-namespaced to Somnambulist\\Components.
src/Doctrine/Enumerations · medium confidence
Refactored event system with new base class and interface
The event handling system has been refactored to improve consistency and support anonymous classes. The old \AbstractDomainEvent\ and \AbstractEventPublisher\ classes have been replaced by a new \AbstractEvent\ base class and an \EventDecoratorInterface\. This change introduces a \GenericEvent\ fallback for deserialization and updates the event structure to use \FrozenCollection\ for payload and context data, while removing the previous domain event publisher implementations.
src/Events · high confidence
Removal of domain entity and event contracts and traits
The domain layer has been refactored by removing several core contracts and traits that previously defined entity states and event handling. Specifically, the \Activatable\, \AggregateRoot\, \HasEqualityInterface\, \HasSurrogateIdentifier\, \Identifiable\, \Nameable\, \NumericallySortable\, \Publishable\, \StringableInterface\, and \Timestampable\ interfaces have been deleted. Additionally, the \RaisesDomainEvents\ interface and the \RaisesDomainEvents\ and \ProxyableEvent\ traits have been removed, along with the \InvalidPropertyException\ and the \DomainEventPublisher\ for Laravel. This indicates a significant architectural shift in how entities are structured and how domain events are managed within the application.
(repo-wide) · high confidence
Removal of legacy IP address entity classes
The \IPv4Address\, \IPv6Address\, and \IpAddress\ classes in the \Somnambulist\\Domain\\Entities\\Types\\Web\ namespace have been removed. This change eliminates the previous IP address value object implementations, likely as part of a larger refactoring or namespace reorganization.
src/Entities/Types/Web · medium confidence
Removed entity behaviour traits
The Nameable, Stringable, Timestampable, and Versionable traits have been removed from the codebase. This removes the automatic management of entity names, string representations, timestamps, and version numbers from the domain entities.
src/Entities/Behaviours · high confidence
Removed legacy Geography and Money value objects
The Country, Srid, and Money value objects have been removed from the codebase. This eliminates the old namespace structures (Somnambulist\\Domain\\Entities\\Types\\Geography and Money) and their associated data mappings, likely as part of a larger refactoring or migration to a new domain model.
src/Entities/Types/Geography · high confidence
Update PHPUnit configuration for version 12.4
The PHPUnit configuration file has been updated to version 12.4, which introduces a new XML schema and replaces the deprecated \\<filter\>\ and \\<whitelist\>\ sections with the modern \\<source\>\ and \\<exclude\>\ structure. Additionally, the test suite name has been changed from 'Application Test Suite' to 'Project Test Suite', and the cache directory is now explicitly configured.
(repo-wide) · high confidence
Test coverage
Add tests for AbstractPaginatableQuery; Added comprehensive test coverage for domain models and value objects; Added test bootstrap file; Added test stubs for custom Doctrine types; Added test stubs for domain models and helpers; Added test stubs for event bus and domain event listener; Added test stubs for event handling and event classes; Added test support infrastructure for kernel booting and Doctrine setup; Added tests for assertion helpers, entity accessor, and identity generator utilities; Added tests for event decorator functionality; New test assertion helpers for domain events and entity properties; Removed entity type tests; Removed test fixtures for domain events; Updated Doctrine test suite for namespace and API changes; Updated domain event tests for namespace and API changes; Updated test stubs and configuration for the new namespace; Updated tests for event publishers.
Dependencies
Major version upgrade and PHP 8.4+ requirement
The package now requires PHP 8.4 or higher, marking a significant shift from the previous PHP 7.2+ requirement. Several dependencies have been updated to major new versions: \somnambulist/collection\ to v5.5, \ramsey/uuid\ to v4.9, and \beberlei/assert\ to v3.3. Additionally, the namespace structure has been reorganized from \Somnambulist\\Domain\ to \Somnambulist\\Components\ across commands, models, events, jobs, queries, and utilities, which will require updating class references in user code.
(dependencies) · high confidence
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
This is the PUBLIC form of this artifact. Findings are listed in full, but the details of SECURITY findings — which rule fired, in which file, on which line, and how to fix it — are deliberately withheld, and any secret-scanner results are excluded entirely. Where detail is absent here it was REMOVED FOR PUBLICATION; it is not missing from the analysis. The complete artifact is available from the repository owner.
Score
- CAI 59 → 66 (+7.9)
- Rubric changed (rubric-2026.08.19 → rubric-2026.09.15) — scores are not directly comparable.
Lenses
- Code Health 97 → 98 (+0.9)
- Architecture 100 → 95 (-4.7)
- Maturity 59 → 58 (-0.6)
- Readiness 46 → 62 (+16.6)
- Security 67 → 75 (+8.3)
Resolved (5)
- Coverage not included — suite not readable by the collector
- Dependency hygiene not measured — dependency manifest found but not parsed for hygiene
- No exposed public API
- Test reliability not included
- dormant codebase — no living knowledge left to concentrate
New (20)
- Ambiguous naming for identical lookup behavior. get() and findOrFail() in the FindOrFail behavior appear to perform the same lookup (likely throwing on failure given the behavior name), but the naming suggests get might return null or a different result type. If they are identical, one is redundant.
- Dependency hygiene PARTLY measured — Composer dependencies read, no committed lock to grade for currency
- Documentation: no installation or build instructions (README.md)
- Documentation: no usage examples (README.md)
- Duplicated block (10 lines × 2) (src/Models/AbstractEntity.php)
- Duplicated block (15 lines × 2) (src/Doctrine/Types/AbstractIdentityType.php)
- Duplicated block (15 lines × 3) (src/Doctrine/Types/Identity/EmailAddressType.php)
- Duplicated block (5 lines × 2) (src/Models/Types/Geography/Country.php)
- Duplicated block (7 lines × 2) (src/Doctrine/Behaviours/QueryBuilder/HasGroupByColumn.php)
- Excessive aliasing of comparison methods. The API exposes both short aliases (eq, ne, gt, gte, lt, lte) and their full English equivalents (notEqualTo, greaterThan, etc.). This doubles the surface area for identical operations without adding distinct semantic value.
- High: security finding (details withheld)
- High: security finding (details withheld)
- No assertions: testInjectRequestId (tests/Events/Decorators/EventDecoratorsTest.php)
- No assertions: testInjectUserData (tests/Events/Decorators/EventDecoratorsTest.php)
- No assertions: testMultipleEvents (tests/Events/Decorators/EventDecoratorsTest.php)
- No dependency advisory monitoring
- Orphaned files with no living knowledge
- Redundant aliasing for min/max operations. Both min/max and minimum/maximum are exposed for the same functionality.
- Redundant methods for string conversion. Both toString() and __toString() are exposed. While __toString is required for implicit casting, exposing toString() as a public API method creates confusion about which should be used explicitly.
- Redundant methods for string conversion. Similar to AbstractEnumeration, Stringable exposes both __toString() and toString().
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
somnambulist-tech/domain 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 21 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit 435d79c79bfbe434d42fa17ed7b2bde1683dc887 — the exact code this score is about.
- Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-fa71c66cabd8.