2020-05-31 20:41:16 +02:00
|
|
|
<?php namespace MapGuesser\Response;
|
2020-05-19 03:13:55 +02:00
|
|
|
|
2020-05-31 20:41:16 +02:00
|
|
|
class JsonContent extends ContentBase
|
2020-05-19 03:13:55 +02:00
|
|
|
{
|
|
|
|
public function __construct(array &$data = [])
|
|
|
|
{
|
|
|
|
$this->data = &$data;
|
|
|
|
}
|
|
|
|
|
2020-06-27 12:56:47 +02:00
|
|
|
public function render(): void
|
2020-05-19 03:13:55 +02:00
|
|
|
{
|
2020-06-27 01:19:17 +02:00
|
|
|
$this->data['__debug__runtime'] = round((hrtime(true) - SCRIPT_STARTED) / 1e+6, 1);
|
|
|
|
|
2020-06-27 12:56:47 +02:00
|
|
|
echo json_encode($this->data);
|
2020-05-19 03:13:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getContentType(): string
|
|
|
|
{
|
|
|
|
return 'application/json';
|
|
|
|
}
|
|
|
|
}
|