Skip to content

Commit 77fc22e

Browse files
committed
JsonResponse class creted.
1 parent ac92a66 commit 77fc22e

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/JsonResponse.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
/**
3+
* JsonResponse.php
4+
*
5+
* This file is part of InitPHP.
6+
*
7+
* @author Muhammet ŞAFAK <[email protected]>
8+
* @copyright Copyright © 2022 InitPHP
9+
* @license http://initphp.github.com/license.txt MIT
10+
* @version 1.0.1
11+
* @link https://www.muhammetsafak.com.tr
12+
*/
13+
14+
declare(strict_types=1);
15+
16+
namespace InitPHP\HTTP;
17+
18+
use function json_encode;
19+
20+
/**
21+
* @since 1.0.1
22+
*/
23+
class JsonResponse extends Response
24+
{
25+
public function __construct(array $data, int $status = 200, string $version = '1.1')
26+
{
27+
$body = new Stream(json_encode($data), null);
28+
parent::__construct($status, ['Content-Type' => 'application/json'], $body, $version, null);
29+
}
30+
}

0 commit comments

Comments
 (0)