mapguesser/src/Response/JsonContent.php

22 lines
446 B
PHP
Raw Normal View History

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