Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| FetchResult | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\ResourceLoader; |
| 6 | |
| 7 | /** |
| 8 | * Successful fetch result. Immutable. |
| 9 | * |
| 10 | * `bytes` is the raw response body. `mimeType` is the sniffed type |
| 11 | * (`Content-Type` is treated as a hint, not authoritative — we sniff |
| 12 | * the bytes the same way browsers do for `<image>`, `<img>`, `<font>`, |
| 13 | * `<style>`). `originalUrl` is what the caller asked for; `finalUrl` |
| 14 | * is the post-redirect URL the body actually came from. |
| 15 | */ |
| 16 | final readonly class FetchResult |
| 17 | { |
| 18 | /** |
| 19 | * @param string $bytes Raw response body. |
| 20 | * @param string $mimeType Sniffed MIME (e.g. `image/png`). |
| 21 | * @param string $originalUrl URL passed to `fetch()`. |
| 22 | * @param string $finalUrl URL after redirect chain. |
| 23 | * @param bool $cacheHit True if the body came from cache. |
| 24 | * @param int $statusCode HTTP status of the final response. |
| 25 | */ |
| 26 | public function __construct( |
| 27 | public string $bytes, |
| 28 | public string $mimeType, |
| 29 | public string $originalUrl, |
| 30 | public string $finalUrl, |
| 31 | public bool $cacheHit, |
| 32 | public int $statusCode, |
| 33 | ) {} |
| 34 | } |