withAttributes

Learn how to set the context attributes for the content.

This method sets the context attributes for the content, replacing any existing ones.

Signature

This method has the following signature:

public function withAttributes(array $attributes): self

This method returns a copy of the options with the change applied, leaving the original unchanged.

Example

Here is a basic example of how to use this method:

<?phpuse Croct\Plug\FetchOptions;
$options = FetchOptions::defaults()->withAttributes(['plan' => 'premium']);

Parameters

The following list describes the supported parameters:

attributes
array

The context attributes for the content, replacing any existing ones.