Skip to content

feat: Make the model mutable - #24

Merged
odolbeau merged 1 commit into
mainfrom
feat-mutable
Oct 3, 2026
Merged

odolbeau merged 1 commit into
mainfrom
feat-mutable

Conversation

@odolbeau

@odolbeau odolbeau commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Editing an imported Card meant rebuilding every object, copying each of its arguments by hand. Model classes are no longer read-only:

$card = (new VCardDecoder())->decode($vCard)[0]->value;
$card->name->full = 'Jane Doe';
$card->emails['EMAIL-1']->address = 'jane@example.com';
$card->phones['work'] = new Phone('+33 1 23 45 67 89', contexts: [Context::WORK]);
unset($card->notes['NOTE-1']);
  • readonly removed from the 30 classes of src/Model; they stay final, typed, with promoted properties.
  • The encoders still validate the Card when they write it; nothing is checked on assignment.
  • clone stays shallow: the README points to myclabs/deep-copy, added to suggest, for an independent copy.
  • Importer: three object rebuilds become plain assignments (withGeography() removed, linkTitles(), the JSPROP fallback in patch()).
  • README: new "Editing a Card" section; CHANGELOG entry under Unreleased.
  • New tests/Model/EditingTest.php: decode, edit, and check the exact vCard 4.0 and JSON output.

make qa passes.

🤖 Generated with Claude Code

Editing an imported Card meant rebuilding every object on the way, copying
each of its arguments by hand. Model classes are no longer read-only: set
their properties, add or remove map entries, and write the Card again. The
encoders still validate the Card when they write it.

clone stays shallow; the README points to myclabs/deep-copy, now suggested,
for an independent copy. The importer drops the rebuilds it needed too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@odolbeau
odolbeau merged commit 34a258a into main Oct 3, 2026
4 checks passed
@odolbeau
odolbeau deleted the feat-mutable branch October 3, 2026 14:48
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.

1 participant