1 | <?php |
||
11 | class ServerTimingMiddleware |
||
12 | { |
||
13 | /** @var ServerTiming */ |
||
14 | protected $timing; |
||
15 | |||
16 | /** @var float|mixed|string */ |
||
17 | protected $start; |
||
18 | |||
19 | /** |
||
20 | * ServerTimingMiddleware constructor. |
||
21 | * @param ServerTiming $timing |
||
22 | */ |
||
23 | public function __construct(ServerTiming $timing) |
||
28 | |||
29 | /** |
||
30 | * @param Request $request |
||
31 | * @param Closure $next |
||
32 | * @return mixed|Response |
||
33 | */ |
||
34 | public function handle(Request $request, Closure $next) |
||
57 | |||
58 | /** |
||
59 | * Getting elapsed time in milliseconds |
||
60 | * @return float|int |
||
61 | */ |
||
62 | protected function getElapsedTimeInMs() |
||
66 | |||
67 | /** |
||
68 | * Getting request start time in milliseconds |
||
69 | * @return float|mixed|string |
||
70 | */ |
||
71 | protected function getRequestStartTime() |
||
79 | |||
80 | /** |
||
81 | * Generate Server-Timing headers |
||
82 | * @return string |
||
83 | */ |
||
84 | protected function generateHeaders(): string |
||
102 | } |
||
103 |