blob: fe42c15024da7f5c529631e0623a10e6738d4106 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
<?php
declare(strict_types=1);
namespace AugustOffensive\View;
use AugustOffensive\Model;
/**
* Output formats for Results that are returned to the client.
*/
class Output
{
/**
* Formats the result into JSON.
*
* @param Model\Result $result The result to return to the client.
* @param bool $prepare Whether to set the content type of the response (default true).
*
* @return string
*/
public static function json (Model\Result $result, bool $prepare = true): string
{
// breaks side effect rule?
if ($prepare) {
header("Content-Type: application/json");
}
return json_encode(array(
"Result-Type" => $result->getResultType(),
"Content" => $result->getResult()
));
}
}
|