Added hasCookie method to HttpRequest.

This commit is contained in:
Pachira 2023-08-16 23:03:01 +00:00
parent 553b7c4a14
commit a4c1d5627e
2 changed files with 6 additions and 2 deletions

View file

@ -1 +1 @@
0.2308.30129
0.2308.162302

View file

@ -1,7 +1,7 @@
<?php
// HttpRequest.php
// Created: 2022-02-08
// Updated: 2023-01-07
// Updated: 2023-08-16
namespace Index\Http;
@ -72,6 +72,10 @@ class HttpRequest extends HttpMessage {
return filter_var($this->cookies[$name] ?? null, $filter, $options);
}
public function hasCookie(string $name): bool {
return isset($this->cookies[$name]);
}
public static function fromRequest(): HttpRequest {
$build = new HttpRequestBuilder;
$build->setHttpVersion(new Version(...array_map('intval', explode('.', substr($_SERVER['SERVER_PROTOCOL'], 5)))));