Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
DefaultPreviewStrategy | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
4 | |
100.00% |
1 / 1 |
handlePreviewResponse | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
4 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace Ndrstmr\Icap; |
6 | |
7 | use Ndrstmr\Icap\DTO\IcapResponse; |
8 | use Ndrstmr\Icap\Exception\IcapResponseException; |
9 | |
10 | /** |
11 | * Default strategy for interpreting preview responses. |
12 | */ |
13 | class DefaultPreviewStrategy implements PreviewStrategyInterface |
14 | { |
15 | /** |
16 | * Decide whether to continue sending the body after a preview response. |
17 | */ |
18 | public function handlePreviewResponse(IcapResponse $previewResponse): PreviewDecision |
19 | { |
20 | return match ($previewResponse->statusCode) { |
21 | 204 => PreviewDecision::ABORT_CLEAN, |
22 | 100 => PreviewDecision::CONTINUE_SENDING, |
23 | default => throw new IcapResponseException('Unexpected preview status code: ' . $previewResponse->statusCode), |
24 | }; |
25 | } |
26 | } |