/
TheDmitry
/
game1
Обзор
Документация
Войти
/
TheDmitry
/
game1
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
core/Request.php
47 строк
1018 B
TheDmitry
Initial commit
18 мар 2025, 09:40
18 мар 2025, 09:40
bf14e7b
Код
Авторство
О чём код?
<?php namespace Game\Core; use \Game\Core\Traits\Singleton; class Request { use Singleton; private array $args = []; private function __construct() { if ($this->isPost()) $this->args = json_decode(file_get_contents('php://input'), true, 512, JSON_THROW_ON_ERROR); else if ($this->isGet()) $this->args = $_GET; else $this->args = []; } public function getMethod(): string { return $_SERVER['REQUEST_METHOD']; } public function getUrl(): string { return $_SERVER['REQUEST_URI']; } public function getQueryString(): string { return $_SERVER['QUERY_STRING']; } public function isPost(): bool { return $_SERVER['REQUEST_METHOD'] === 'POST'; } public function isGet(): bool { return $_SERVER['REQUEST_METHOD'] === 'GET'; } public function getArgs(): array { return $this->args; } public function getArg($key) { return $this->args[$key] ?? null; } }