evaluate

Learn how to evaluate a CQL query.

This method evaluates a CQL query against the visitor’s context in real-time.

For more information, see Query evaluation.

Signature

This method has the following signature:

public function evaluate(string $query, ?EvaluationOptions $options = null): mixed

This method returns the result of the evaluation, whose type depends on the query. If the request fails and no fallback is set, it throws an exception.

Example

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

<?phpuse Croct\Plug\Croct;
$croct = Croct::fromDotenv();$returning = $croct->evaluate('user is returning');

Parameters

The following list describes the supported parameters:

query
string

The CQL query to evaluate.

options(optional)

The evaluation options, such as a fallback or attributes.