diff --git a/system/Superglobals.php b/system/Superglobals.php index 65ab800e98f3..4c2f7bd6e445 100644 --- a/system/Superglobals.php +++ b/system/Superglobals.php @@ -18,18 +18,29 @@ */ final class Superglobals { + private array $server; + private array $get; + + public function __construct(?array $server = null, ?array $get = null) + { + $this->server = $server ?? $_SERVER; + $this->get = $get ?? $_GET; + } + public function server(string $key): ?string { - return $_SERVER[$key] ?? null; + return $this->server[$key] ?? null; } public function setServer(string $key, string $value): void { - $_SERVER[$key] = $value; + $this->server[$key] = $value; + $_SERVER[$key] = $value; } public function setGetArray(array $array): void { - $_GET = $array; + $this->get = $array; + $_GET = $array; } }