PHP8
[m6w6/seekat] / lib / API / ContentType / Handler / Stream.php
diff --git a/lib/API/ContentType/Handler/Stream.php b/lib/API/ContentType/Handler/Stream.php
new file mode 100644 (file)
index 0000000..6a8535e
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+
+namespace seekat\API\ContentType\Handler;
+
+use http\Message\Body;
+use seekat\API\ContentType\Handler;
+
+final class Stream implements Handler {
+       /**
+        * @inheritdoc
+        */
+       function types() : array {
+               return ["application/octet-stream"];
+       }
+
+       /**
+        * @inheritdoc
+        * @param resource $data
+        */
+       function encode($data): Body {
+               return new Body($data);
+       }
+
+       /**
+        * @inheritdoc
+        * @return resource
+        */
+       function decode(Body $body) {
+               return $body->getResource();
+       }
+}