<?php

namespace engine\http;

class JSONResponse
    extends Response
{
    public function __construct(mixed $data, HTTPCode $code = HTTPCode::OK) {
        parent::__construct($code);
        $this->data = $data;
    }

    public function getBody(): string {
        return jsonEncode($this->data);
    }

    public function getHeaders(): ?array {
        return ['Content-Type: application/json; charset=utf-8'];
    }
}
