Skip to content

Commit

Permalink
Merge pull request #76 from utopia-php/feat-setter-returns
Browse files Browse the repository at this point in the history
Feat setter returns
  • Loading branch information
eldadfux authored Oct 19, 2022
2 parents f58bd08 + 2d93193 commit d595df0
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ public function getServer(string $key, string $default = null): ?string
*
* @param string $key
* @param string $value
* @return $this
* @return static
*/
public function setServer(string $key, string $value): self
public function setServer(string $key, string $value): static
{
$_SERVER[$key] = $value;

Expand Down Expand Up @@ -221,9 +221,9 @@ public function getMethod(): string
* Set HTTP request method
*
* @param string $method
* @return self
* @return static
*/
public function setMethod(string $method): self
public function setMethod(string $method): static
{
$this->setServer('REQUEST_METHOD', $method);

Expand All @@ -248,9 +248,9 @@ public function getURI(): string
* Return HTTP request path
*
* @param string $uri
* @return self
* @return static
*/
public function setURI(string $uri): self
public function setURI(string $uri): static
{
$this->setServer('REQUEST_URI', $uri);

Expand Down Expand Up @@ -363,11 +363,13 @@ public function getHeader(string $key, string $default = ''): string
*
* @param string $key
* @param string $value
* @return void
* @return static
*/
public function addHeader(string $key, string $value): void
public function addHeader(string $key, string $value): static
{
$this->headers[$key] = $value;

return $this;
}

/**
Expand All @@ -376,13 +378,15 @@ public function addHeader(string $key, string $value): void
* Method for removing HTTP header parameters.
*
* @param string $key
* @return void
* @return static
*/
public function removeHeader(string $key): void
public function removeHeader(string $key): static
{
if (isset($this->headers[$key])) {
unset($this->headers[$key]);
}

return $this;
}

/**
Expand Down Expand Up @@ -516,22 +520,26 @@ public function getRangeUnit(): ?string
* Set query string parameters
*
* @param array $params
* @return void
* @return static
*/
public function setQueryString(array $params)
public function setQueryString(array $params): static
{
$this->queryString = $params;

return $this;
}

/**
* Set payload parameters
*
* @param array $params
* @return void
* @return static
*/
public function setPayload(array $params)
public function setPayload(array $params): static
{
$this->payload = $params;

return $this;
}

/**
Expand Down

0 comments on commit d595df0

Please sign in to comment.