Skip to content

Commit

Permalink
added file for request
Browse files Browse the repository at this point in the history
  • Loading branch information
Desmond Chin authored and Desmond Chin committed Jan 3, 2021
1 parent d8ed3a8 commit e29e23c
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/Http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ class Request
*/
private array $query = [];

/**
* Holds the files of the request
*/
private array $files = [];

/**
* The method of the request.
*/
Expand Down Expand Up @@ -47,6 +52,10 @@ public function __construct()
*/
$this->query = $query;

foreach ((array) $_FILES as $k => $v) {
$this->files[$k] = $v;
}

/**
* Sets the request URI
*/
Expand Down Expand Up @@ -105,7 +114,7 @@ public function header(?string $headerKey = null) {
* @param string $key The query name.
* @return string|array The query value or array of all queries.
*/
public function query(?string $key = null) : array
public function query(?string $key = null)
{
if(empty($key)){
return $this->query;
Expand All @@ -114,6 +123,21 @@ public function query(?string $key = null) : array
return $this->query[$key] ?? null;
}

/**
* Returns the request files.
*
* @param string $key The file name.
* @return string|array The file or array of all files.
*/
public function file(?string $key = null)
{
if(empty($key)){
return $this->files;
}

return $this->files[$key] ?? null;
}

/**
* Set the local value by key of the request.
*
Expand Down

0 comments on commit e29e23c

Please sign in to comment.