a8e29d0305
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
33 lines
624 B
PHP
33 lines
624 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace KTXC\Http\Request;
|
|
|
|
/**
|
|
* Holds the HTTP request for the duration of the current runtime execution.
|
|
*/
|
|
final class RequestContext
|
|
{
|
|
private ?Request $request = null;
|
|
|
|
public function initialize(Request $request): void
|
|
{
|
|
if ($this->request !== null) {
|
|
throw new \LogicException('The request context has already been initialized.');
|
|
}
|
|
|
|
$this->request = $request;
|
|
}
|
|
|
|
public function current(): ?Request
|
|
{
|
|
return $this->request;
|
|
}
|
|
|
|
public function clear(): void
|
|
{
|
|
$this->request = null;
|
|
}
|
|
}
|