<?php
namespace myFrame;
class Response
{
protected $data = '';
protected $header = [];
protected $code = 200;
public function __construct($data, $header, $code)
{
$this->data=$data;
$this->header=\array_merge($this->header, $header);
$this->code=$code;
}
public function send()
{
\http_response_code($this->code);
foreach ($this->header as $key => $value) {
header($key.(isset($value) ? ":$value" : ''));
}
echo $this->data;
}
public static function create($data = '', $header = [], $code = 200): Response
{
return new static($data, $header, $code);
}
}