27 lines
557 B
PHP
27 lines
557 B
PHP
|
<?php
|
||
|
|
||
|
declare(strict_types=1);
|
||
|
|
||
|
final class ApiJsonResponse extends ApiResponse
|
||
|
{
|
||
|
protected string $mimeType = MimeType::JSON;
|
||
|
|
||
|
public function __construct(int $status = ServerStatus::OK)
|
||
|
{
|
||
|
parent::__construct($status);
|
||
|
|
||
|
$this->setParameter('success', true);
|
||
|
}
|
||
|
|
||
|
public function setResult(JsonSerializable $result): void
|
||
|
{
|
||
|
$this->setParameter('result', $result->jsonSerialize());
|
||
|
}
|
||
|
|
||
|
public function respond(): void
|
||
|
{
|
||
|
parent::respond();
|
||
|
|
||
|
echo json_encode($this->parameters);
|
||
|
}
|
||
|
}
|