Skip to content

feat!: Pass the encoder target per call - #23

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

odolbeau merged 1 commit into
mainfrom
feat-improve-dialects

Conversation

@odolbeau

@odolbeau odolbeau commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

The vCard version and the dialects both depend on the address book the vCard is written for, which is known when encoding, not when building the encoder. The version was already passed per call, the dialects were not.

Changes

  • Target: the vCard version and the dialects VCardEncoder writes for, with ready-made Target::apple() (3.0, LegacyMessaging + Apple) and Target::android() (3.0, LegacyMessaging + Android; Android exports 2.1, which the encoder does not write).
  • Dialects::all(): every dialect, for VCardDecoder. Each dialect reads only its own vendor properties, so reading with all of them is safe when the source is unknown.
  • Breaking: VCardEncoder::encode() / convert() take a Target instead of a VCardVersion, and the constructor no longer takes dialects.
  • Breaking: dialects write in the order given, no longer in reverse. The reverse order only served to share one list with the decoder.
  • README and CHANGELOG updated.

Usage

$results = (new VCardDecoder(dialects: Dialects::all()))->decode($vCards);
$result = (new VCardEncoder())->encode($card, Target::apple());
$result = (new VCardEncoder())->encode($card, new Target(VCardVersion::V30, [new LegacyMessaging()]));

Tests

make qa passes (340 tests). The fixture round trips now decode with Dialects::all() and encode with the preset of the address book each fixture comes from.

🤖 Generated with Claude Code

The address book a vCard is written for is known at encoding time, not when the
encoder is built: VCardEncoder::encode() and convert() now take a Target, the
vCard version and the dialects that address book reads, instead of a
VCardVersion. Target::apple() and Target::android() are ready-made.

Dialects now write in the order given. The reverse order only served to share
one list between the decoder and the encoder; the decoder reads with every
dialect instead, through Dialects::all().

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