Skip to content

Commit 239b2cc

Browse files
committed
feat: allow Superglobals state changes from the constructor
1 parent b2e8c02 commit 239b2cc

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

system/Superglobals.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,29 @@
1818
*/
1919
final class Superglobals
2020
{
21+
private array $server;
22+
private array $get;
23+
24+
public function __construct(?array $server = null, ?array $get = null)
25+
{
26+
$this->server = $server ?? $_SERVER;
27+
$this->get = $get ?? $_GET;
28+
}
29+
2130
public function server(string $key): ?string
2231
{
23-
return $_SERVER[$key] ?? null;
32+
return $this->server[$key] ?? null;
2433
}
2534

2635
public function setServer(string $key, string $value): void
2736
{
28-
$_SERVER[$key] = $value;
37+
$this->server[$key] = $value;
38+
$_SERVER[$key] = $value;
2939
}
3040

3141
public function setGetArray(array $array): void
3242
{
33-
$_GET = $array;
43+
$this->get = $array;
44+
$_GET = $array;
3445
}
3546
}

0 commit comments

Comments
 (0)