Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
87.50% |
7 / 8 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| Profiler | |
87.50% |
7 / 8 |
|
0.00% |
0 / 1 |
3.02 | |
0.00% |
0 / 1 |
| __invoke | |
87.50% |
7 / 8 |
|
0.00% |
0 / 1 |
3.02 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace BO\Slim\Middleware; |
| 4 | |
| 5 | use Psr\Http\Message\ServerRequestInterface; |
| 6 | use Psr\Http\Message\ResponseInterface; |
| 7 | use Psr\Http\Server\RequestHandlerInterface; |
| 8 | use BO\Slim\Factory\ResponseFactory; |
| 9 | |
| 10 | class Profiler |
| 11 | { |
| 12 | /** |
| 13 | * |
| 14 | */ |
| 15 | public function __invoke(ServerRequestInterface $request, ?RequestHandlerInterface $next): ResponseInterface |
| 16 | { |
| 17 | \BO\Slim\Profiler::add("Routing"); |
| 18 | if (null !== $next) { |
| 19 | $response = $next->handle($request); |
| 20 | } else { |
| 21 | $response = (new ResponseFactory())->createResponse(); |
| 22 | } |
| 23 | |
| 24 | if (\App::DEBUG) { |
| 25 | \BO\Slim\Profiler::addMemoryPeak(); |
| 26 | $response = $response->withAddedHeader('X-Profiling', \BO\Slim\Profiler::getList()); |
| 27 | } |
| 28 | |
| 29 | return $response; |
| 30 | } |
| 31 | } |