update to PHP-8.1
[m6w6/seekat] / lib / API / ContentType / Handler / Stream.php
1 <?php
2
3 namespace seekat\API\ContentType\Handler;
4
5 use http\Message\Body;
6 use seekat\API\ContentType\Handler;
7
8 final class Stream implements Handler {
9 /**
10 * @inheritdoc
11 */
12 function types() : array {
13 return ["application/octet-stream"];
14 }
15
16 /**
17 * @inheritdoc
18 * @param resource $data
19 */
20 function encode(mixed $data): Body {
21 return new Body($data);
22 }
23
24 /**
25 * @inheritdoc
26 * @return resource
27 */
28 function decode(Body $body) : mixed {
29 return $body->getResource();
30 }
31 }