Method
HttpClientOptions::overrideFrom
Return a copy of this instance with the non-null values of $options applied on top.
Description#
public HttpClientOptions::overrideFrom(
HttpClientOptions|array|null $options
): HttpClientOptionsA null value never overwrites a set option, so a default cannot be cleared this way. An
array value replaces the old array. false and 0 are values like any other.
Parameters#
- $options HttpClientOptions|array|null
- The values to apply
Return values#
HttpClientOptions
Errors / Exceptions#
| Exception | When |
|---|---|
InvalidArgumentException | For an option name that is not a property |
Examples#
$defaults = new HttpClientOptions(['timeoutMs' => 5000, 'headers' => ['Accept: text/html']]);
$one = $defaults->overrideFrom(['timeoutMs' => 100]);
// $one->timeoutMs is 100, $one->headers is still ['Accept: text/html']; $defaults is unchangedSee also#
HttpClient::requestSend a request with any method, a body and options for this request only.