Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
66.67% |
2 / 3 |
CRAP | |
42.86% |
6 / 14 |
| Kernel | |
0.00% |
0 / 1 |
|
66.67% |
2 / 3 |
6.99 | |
42.86% |
6 / 14 |
| __construct | |
100.00% |
1 / 1 |
1 | |
100.00% |
3 / 3 |
|||
| buildResponse | |
100.00% |
1 / 1 |
1 | |
100.00% |
3 / 3 |
|||
| deliverResponse | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 8 |
|||
| <?php | |
| namespace Luxian\Http; | |
| use Luxian\Common\SystemProxy; | |
| use Luxian\Container\ContainerInterface; | |
| class Kernel | |
| { | |
| /** @var ContainerInterface */ | |
| private $container; | |
| /** @var SystemProxy */ | |
| private $system; | |
| public function __construct(ContainerInterface $container, SystemProxy $php) | |
| { | |
| $this->container = $container; | |
| $this->system = $php; | |
| } | |
| public function buildResponse(Request $request): Response | |
| { | |
| $router = $this->container->getRouter(); | |
| $callback = $router->getRequestCallback($request, $this->container); | |
| return $callback($request); | |
| } | |
| public function deliverResponse(Response $response): void | |
| { | |
| foreach ($response->getHeaders() as $header) { | |
| $this->system->sendHttpHeader( | |
| sprintf( | |
| '%s: %s;', | |
| $header->getName(), | |
| $header->getValue() | |
| ) | |
| ); | |
| } | |
| echo $response->getBody(); | |
| } | |
| } |