<?php
namespace ProVM\Common\Basic;

use Psr\Http\Message\ResponseInterface as Response;
use ProVM\Common\Definition\Controller as ControllerInterface;

abstract class Controller implements ControllerInterface {
  public function withJSON(Response $response, string $data): Response {
    $response->getBody()->write(json_encode($data));
    return $response
      ->withHeader('Content-Type', 'application/json')
      ->withStatus(201);
  }
  public function withRedirect(string $uri): Response {
    return $response
      ->withHeader('Location', $uri)
      ->withStatus(303);
  }
}
