Evaluator

Introduction

The evaluator service is a simple class that recursively resolves values from a mixed target.

Basic Usage

You can evaluate your values by using the \Anomaly\Streams\Platform\Support\Evaluator class.

evaluate

The evaluate method evaluates a mixed value with the provided arguments.

$evaluator = app(\Anomaly\Streams\Platform\Support\Evaluator::class);

$evaluator->evaluate($target, $entry);
{{ value($target, $entry) }}
$entry = new Person(['name' =>'Ryan']);

$evaluator->evaluate('{entry.name}', compact('entry'));
// Ryan

$evaluator->evaluate(
    function($entry) {
        return $entry->name;
    },
    compact('entry')
); // Ryan
{{ value('{entry.name}', entry) }}

Evaluation is used heavily in the build process for UI builders.