feat: implement global autoresponder plugin
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
final class Http
|
||||
{
|
||||
public static function method(): string
|
||||
{
|
||||
return strtoupper((string)($_SERVER['REQUEST_METHOD'] ?? 'GET'));
|
||||
}
|
||||
|
||||
public static function isPost(): bool
|
||||
{
|
||||
return self::method() === 'POST';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string,mixed> $source
|
||||
*/
|
||||
public static function getString(array $source, string $key, string $default = ''): string
|
||||
{
|
||||
$value = $source[$key] ?? $default;
|
||||
return is_scalar($value) ? trim((string)$value) : $default;
|
||||
}
|
||||
|
||||
public static function redirect(string $url): void
|
||||
{
|
||||
header('Location: ' . $url, true, 302);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user