3 namespace seekat\API\ContentType\Handler
;
6 use seekat\API\ContentType\Handler
;
7 use seekat\Exception\InvalidArgumentException
;
8 use function seekat\typeof
;
10 final class Text
implements Handler
{
14 function types() : array {
15 return ["sha", "raw", "html", "diff", "patch", "text/plain"];
22 function encode($data): Body
{
23 if (isset($data) && !is_scalar($data)) {
24 throw new InvalidArgumentException(
25 "Text encoding argument must be scalar, got ".typeof($data));
27 return (new Body
)->append($data);
34 function decode(Body
$body) {
35 return (string) $body;