Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Earlier releases (`v0.1.0-alpha.1` to `v0.1.7-alpha.1`) were experimental and do

---

## [v0.1.7-alpha.2] - YYYY-MM-DD
## [v0.1.7-alpha.2] - 2025-07-15

### Changed

Expand Down
25 changes: 22 additions & 3 deletions core/Http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,40 @@

namespace Core\Http;

class Request {
class Request
{
public $method, $uri;

private function __construct($method, $uri) {
private function __construct($method, $uri)
{
$this->method = $method;
$this->uri = $uri;
}

/**
* Static method that reads the HTTP method + URI and returns a new Request object
*/
public static function capture(){
public static function capture()
{
$method = $_SERVER['REQUEST_METHOD'];
$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);

return new self($method, $uri);
}

/**
* File method to get the input files
*/
public function file($key)
{
return $_FILES[$key] ?? null;
}

/**
* File method to check if input is file
*/
public function hasFile($key)
{
return isset($_FILES[$key]) && is_uploaded_file($_FILES[$key]['tmp_name']);
}
}