Skip to content

5.3.0

Choose a tag to compare

@Chemaclass Chemaclass released this 07 Nov 23:46
· 138 commits to main since this release
ae8c1ce

This release focuses on improving developer experience with powerful new features while maintaining full backward compatibility.

πŸ” Fluent Query API

Chain filters and transformations for elegant segment querying:

// Find German suppliers
$suppliers = $message->query()
    ->withTag('NAD')
    ->withSubId('SU')
    ->where(fn($s) => $s->countryCode() === 'DE')
    ->limit(10)
    ->get();

// Extract company names
$names = $message->query()
    ->withTag('NAD')
    ->map(fn($s) => $s->name());

Features:

  • Filtering: withTag(), withTags(), withSubId(), where(), ofType()
  • Pagination: limit(), skip()
  • Access: first(), last(), get()
  • Aggregation: count(), exists(), isEmpty()
  • Transformation: map(), each()

✨ Typed Accessor Methods

Replace magic array indices with self-documenting methods:

// Before
$name = $nadSegment->rawValues()[4];

// After
$name = $nadSegment->name();
$city = $nadSegment->city();
$postal = $nadSegment->postalCode();

Enhanced segments:

  • NAD: name(), street(), city(), postalCode(), countryCode()
  • QTY: quantity(), quantityAsFloat(), measureUnit()
  • PRI: price(), priceAsFloat(), priceType()
  • LIN: lineNumber(), itemNumber(), itemTypeCode()
  • DTM: dateTime(), asDateTime() (parses to DateTimeImmutable)
  • RFF: qualifier(), referenceNumber()
  • UNH: messageType(), messageVersionNumber()

πŸ› Debug Helpers

$segment->toArray();  // Convert to array
$segment->toJson();   // Pretty-print JSON
$message->messageType();  // Quick type detection (ORDERS, INVOIC, etc.)

πŸ“ Enhanced Error Messages

InvalidFile::withContext($errors, ['segment_index' => 42]);
$exception->getErrors();
$exception->getContext();

πŸ“š Documentation & Examples

  • Updated examples to showcase new fluent API
  • Added comprehensive query filtering examples
  • New example/query-filtering.php with 10 practical examples

Full Changelog: 5.2.0...5.3.0