Releases: FriendsOfOuro/http-batch-contract
Releases Β· FriendsOfOuro/http-batch-contract
v3.0.0 - Breaking Interface Changes
π¨ Breaking Changes
This release contains breaking changes to the ResponseBatchInterface:
Method Signature Changes
filter()now returnsstaticinstead ofarrayfor better fluent interface supportgetSuccessfulResults()renamed togetResponses()and returnsResponseInterface[]getFailedResults()renamed togetExceptions()and returnsClientExceptionInterface[]
Migration Guide
Before (v2.x):
$batch = $client->batch($requests);
$results = $batch->getSuccessfulResults(); // BatchItemInterface[]
$failures = $batch->getFailedResults(); // BatchItemInterface[]
$filtered = $batch->filter($predicate); // BatchItemInterface[]After (v3.x):
$batch = $client->batch($requests);
$responses = $batch->getResponses(); // ResponseInterface[]
$exceptions = $batch->getExceptions(); // ClientExceptionInterface[]
$filtered = $batch->filter($predicate); // static (same type as $batch)Benefits
- β Better type safety with specific return types
- β
More semantic method names (
getResponsesvsgetSuccessfulResults) - β
Fluent interface support with
filter()returningstatic - β Direct access to responses and exceptions without wrapping
π€ Generated with Claude Code
v2.0.0
π Major Release: Complete Interface Redesign
Breaking Changes
- ClientInterface: sendRequestBatch() now returns ResponseBatchInterface instead of array
- New Interface Hierarchy: Complete redesign for better type safety and usability
- BatchItemInterface: Individual request/response pairs with getRequest(), isSuccess(), getResponse(), getException()
- ResponseBatchInterface: Batch container with utility methods (extends Countable)
- Exception Redesign: Clear exception hierarchy for access violations
- AccessExceptionInterface: Base interface extending Throwable
- ResponseUnavailableExceptionInterface: When accessing response on failed requests
- ExceptionUnavailableExceptionInterface: When accessing exception on successful requests
New Features
- Rich Utility Methods: isCompleteSuccess(), hasAnyFailures(), hasAnySuccesses(), getSuccessfulResults(), getFailedResults()
- Flexible Filtering: filter() method with callable predicates for custom result filtering
- Countable Interface: ResponseBatchInterface extends Countable for direct count() support
- Type Safety: Eliminated union types in favor of clean holder patterns
- Better Semantics: isSuccess() indicates transport success, not HTTP status codes
Migration Guide
Before (v1.x):
$responses = $client->sendRequestBatch($requests); // array of ResponseInterface
foreach ($responses as $response) {
// Handle response
}After (v2.0):
$batch = $client->sendRequestBatch($requests); // ResponseBatchInterface
// Check overall success
if ($batch->isCompleteSuccess()) {
foreach ($batch->getResults() as $item) {
$response = $item->getResponse();
// Handle successful response
}
} else {
// Handle mixed results
foreach ($batch->getSuccessfulResults() as $item) {
$response = $item->getResponse();
// Process successful responses
}
foreach ($batch->getFailedResults() as $item) {
$exception = $item->getException();
// Handle network failures
}
}
// Direct counting support
$totalRequests = count($batch);Full Changelog: v1.0.1...v2.0.0
v1.0.1
Bug Fixes
- Update exception type in ClientInterface from generic
\Exceptionto more specificClientExceptionInterfaceto align with PSR-18 standards and improve type safety
What's Changed
Full Changelog: v1.0.0...v1.0.1