Skip to content

Strict DDD pass, introduce ModelVersion as a distinct value object, modelVersion() now returns ModelVersion instead of SequenceNumber.#6

Merged
gustavofreze merged 1 commit into
mainfrom
refactor
May 12, 2026
Merged

Strict DDD pass, introduce ModelVersion as a distinct value object, modelVersion() now returns ModelVersion instead of SequenceNumber.#6
gustavofreze merged 1 commit into
mainfrom
refactor

Conversation

@gustavofreze
Copy link
Copy Markdown
Member

No description provided.

…object, modelVersion() now

  returns ModelVersion instead of SequenceNumber.
Copilot AI review requested due to automatic review settings May 12, 2026 12:13
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 update AggregateRoot::modelVersion() to return the new value object.
  • Move SnapshotData into the Snapshot namespace, remove JSON encoding helpers, and add EventRecord::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.

Comment thread src/Aggregate/AggregateRootBehavior.php
Comment thread README.md
Comment thread README.md
Comment thread tests/Aggregate/ModelVersionTest.php
Comment thread tests/Aggregate/ModelVersionTest.php
Comment thread README.md
@gustavofreze gustavofreze merged commit d6031a1 into main May 12, 2026
11 checks passed
@gustavofreze gustavofreze deleted the refactor branch May 12, 2026 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants