1
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-08-03 15:17:33 +02:00

refactor: introduce http Request object (#3926)

This commit is contained in:
Dag
2024-01-25 16:06:24 +01:00
committed by GitHub
parent 9574c17ddc
commit d08d13f2c8
19 changed files with 125 additions and 94 deletions

View File

@@ -166,6 +166,46 @@ final class CurlHttpClient implements HttpClient
}
}
final class Request
{
private array $get;
private array $server;
private function __construct()
{
}
public static function fromGlobals(): self
{
$self = new self();
$self->get = $_GET;
$self->server = $_SERVER;
return $self;
}
public static function fromCli(array $cliArgs): self
{
$self = new self();
$self->get = $cliArgs;
return $self;
}
public function get(string $key, $default = null): ?string
{
return $this->get[$key] ?? $default;
}
public function server(string $key, string $default = null): ?string
{
return $this->server[$key] ?? $default;
}
public function toArray(): array
{
return $this->get;
}
}
final class Response
{
public const STATUS_CODES = [