Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 5
JsonResponse
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 2
12
0.00% covered (danger)
0.00%
0 / 5
 __construct
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 4
 send
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
<?php
declare(strict_types=1);
namespace Eywa\Http\Response {
    use Eywa\Exception\Kedavra;
    class JsonResponse
    {
        /**
         *
         * The redirect url
         *
         */
        private string $url;
        private Response $reponse;
        /**
         *
         *
         * Json response constructor.
         *
         * @param array<mixed> $data
         * @param int $status
         *
         * @throws Kedavra
         *
         */
        public function __construct(array $data, int $status = 200)
        {
            $json = json_encode($data, JSON_FORCE_OBJECT);
            $json = is_bool($json) ? '' : strval($json);
            $this->reponse = new Response($json, '', $status, ['Content-Type' => 'application/json']);
        }
        /**
         *
         * Send the json response
         *
         *
         * @return Response
         *
         */
        public function send(): Response
        {
            return  $this->reponse->send();
        }
    }
}