You are here

public function RequestTrait::withMethod in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/zendframework/zend-diactoros/src/RequestTrait.php \Zend\Diactoros\RequestTrait::withMethod()

Return an instance with the provided HTTP method.

While HTTP method names are typically all uppercase characters, HTTP method names are case-sensitive and thus implementations SHOULD NOT modify the given string.

This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the changed request method.

Parameters

string $method Case-insensitive method.:

Return value

static

Throws

InvalidArgumentException for invalid HTTP methods.

File

vendor/zendframework/zend-diactoros/src/RequestTrait.php, line 186

Class

RequestTrait
Trait with common request behaviors.

Namespace

Zend\Diactoros

Code

public function withMethod($method) {
  $this
    ->validateMethod($method);
  $new = clone $this;
  $new->method = $method;
  return $new;
}