Strict DDD pass, introduce ModelVersion as a distinct value object, modelVersion() now returns ModelVersion instead of SequenceNumber.#6
Merged
Conversation
…object, modelVersion() now returns ModelVersion instead of SequenceNumber.
There was a problem hiding this comment.
Pull request overview
This PR tightens the domain model API toward a more DDD-style vocabulary by replacing get* accessors with intention-revealing methods, introducing ModelVersion as a dedicated value object, and aligning snapshot/event metadata types and documentation accordingly.
Changes:
- Replace legacy
get*methods with domain-named accessors (identity(),identityValue(),sequenceNumber(),aggregateName(),snapshotState(), etc.) across entities, aggregates, and snapshots. - Introduce
Aggregate\ModelVersion(+InvalidModelVersion) and updateAggregateRoot::modelVersion()to return the new value object. - Move
SnapshotDatainto the Snapshot namespace, remove JSON encoding helpers, and addEventRecord::of()factory plus revision comparison helpers.
Reviewed changes
Copilot reviewed 41 out of 41 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Snapshot/SnapshotTest.php | Updates snapshot tests to new snapshot accessor names. |
| tests/Snapshot/SnapshotterBehaviorTest.php | Aligns snapshotter behavior tests with renamed snapshot accessors. |
| tests/Snapshot/SnapshotDataTest.php | Adds unit tests for the relocated SnapshotData value object. |
| tests/Models/OrderWithMissingIdentityProperty.php | Updates fixture override to identityProperty(). |
| tests/Models/Order.php | Removes getStatus() to match the move away from get* accessors. |
| tests/Models/ExplicitCart.php | Updates snapshot and identity hooks + renames getProductIds() usage. |
| tests/Models/CartWithoutHandler.php | Updates model version to return ModelVersion and renames identity hook. |
| tests/Models/CartWithLogger.php | Renames snapshot hook and product accessor; aligns snapshot application. |
| tests/Models/Cart.php | Updates snapshot usage, identity hook, model version type, and accessor naming. |
| tests/Event/SnapshotDataTest.php | Removes old tests for Event\\SnapshotData (now moved). |
| tests/Event/RevisionTest.php | Adds coverage for Revision::isAfter() / isBefore(). |
| tests/Event/EventRecordTest.php | Updates SnapshotData import and adds tests for EventRecord::of(). |
| tests/Event/EventRecordsTest.php | Updates SnapshotData import to new namespace. |
| tests/Entity/SingleIdentityBehaviorTest.php | Renames identity value accessor usage to identityValue(). |
| tests/Entity/EntityBehaviorTest.php | Renames entity identity accessors and updates identity-property semantics. |
| tests/Entity/CompoundIdentityBehaviorTest.php | Renames identity value accessor usage to identityValue(). |
| tests/Aggregate/ModelVersionTest.php | Adds tests for the new ModelVersion value object and validation. |
| tests/Aggregate/EventualAggregateRootBehaviorTest.php | Reflects removal of clearing events + adds snapshot payload expectations. |
| tests/Aggregate/EventSourcingRootBehaviorTest.php | Updates aggregate accessors and snapshot sequencing behavior. |
| tests/Aggregate/AggregateRootBehaviorTest.php | Updates aggregate API tests to sequenceNumber(), modelVersion(), aggregateName(). |
| src/Snapshot/SnapshotEvery.php | Updates snapshot condition to use sequenceNumber(). |
| src/Snapshot/SnapshotData.php | Moves SnapshotData to Snapshot namespace and removes JSON encoding method. |
| src/Snapshot/Snapshot.php | Updates snapshot creation and accessors to non-get* naming. |
| src/Internal/Exceptions/InvalidModelVersion.php | Adds dedicated exception for invalid model versions. |
| src/Event/Revision.php | Adds revision ordering helpers (isAfter, isBefore). |
| src/Event/EventRecord.php | Adds EventRecord::of() factory and updates SnapshotData type reference. |
| src/Entity/SingleIdentityBehavior.php | Renames identity value accessor to identityValue(). |
| src/Entity/SingleIdentity.php | Updates interface docs to new identity accessor name. |
| src/Entity/Identity.php | Renames getIdentityValue() to identityValue() in the contract. |
| src/Entity/EntityBehavior.php | Reworks identity resolution around identityProperty() and renames public methods. |
| src/Entity/Entity.php | Updates public entity API and docs to new identity naming. |
| src/Entity/CompoundIdentityBehavior.php | Renames identity value accessor to identityValue(). |
| src/Entity/CompoundIdentity.php | Updates interface docs to new identity accessor name. |
| src/Aggregate/ModelVersion.php | Introduces ModelVersion value object with invariant enforcement. |
| src/Aggregate/EventualAggregateRootBehavior.php | Removes clearRecordedEvents() behavior to support use-once contract. |
| src/Aggregate/EventualAggregateRoot.php | Removes clearRecordedEvents() from the interface and updates contract docs. |
| src/Aggregate/EventSourcingRootBehavior.php | Applies snapshot sequence via renamed snapshot API and exposes snapshotState(). |
| src/Aggregate/EventSourcingRoot.php | Renames snapshot hook to snapshotState() and updates docs to new snapshot API. |
| src/Aggregate/AggregateRootBehavior.php | Renames aggregate APIs, introduces default ModelVersion, and updates snapshot payload generation. |
| src/Aggregate/AggregateRoot.php | Updates aggregate root contract to new method names and ModelVersion return type. |
| README.md | Refreshes public documentation to reflect the new API, contracts, and behavioral semantics. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.