This commit is contained in:
2023-12-21 17:17:25 +08:00
parent 0167291789
commit e0ac89c1ea
+29
View File
@@ -803,6 +803,35 @@ class Request implements ServerRequestInterface
} }
/**
* @param string $name
* @return bool
*/
public function has(string $name): bool
{
return $this->request($name,null) !== null;
}
/**
* @param string $name
* @param mixed|null $value
* @return mixed
*/
public function request(string $name, mixed $value = null): mixed
{
$parseBody = $this->getParsedBody();
$queryParams = $this->getQueryParams();
if (isset($queryParams[$name])) {
return $queryParams[$name];
}
if (isset($parseBody[$name])) {
return $parseBody[$name];
}
return $value;
}
/** /**
* @return int * @return int
*/ */