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"];
21 function encode(mixed $data): Body
{
22 if (isset($data) && !is_scalar($data)) {
23 throw new InvalidArgumentException(
24 "Text encoding argument must be scalar, got ".typeof($data));
26 return (new Body
)->append((string) $data);
33 function decode(Body
$body) : string {
34 return (string) $body;