Files
elixforms-web-services/src/Api/Core/Request.php
T

27 lines
572 B
PHP

<?php
namespace Api\Core;
class Request {
public function method() {
return $_SERVER['REQUEST_METHOD'];
}
public function path() {
return strtok($_SERVER['REQUEST_URI'], '?');
}
public function body() {
return json_decode(file_get_contents('php://input'), true);
}
public function query() {
return $_GET;
}
public function header(string $name): ?string
{
$key = 'HTTP_' . strtoupper(str_replace('-', '_', $name));
return $_SERVER[$key] ?? null;
}
}