withAttribute

Learn how to add a context attribute to the evaluation.

This method adds a context attribute, identified by a name, to the evaluation.

Signature

This method has the following signature:

public function withAttribute(string $name, mixed $value): 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\EvaluationOptions;
$options = EvaluationOptions::defaults()->withAttribute('plan', 'premium');

Parameters

The following list describes the supported parameters:

name
string

The name that identifies the context attribute.

value
mixed

The value of the context attribute.