public function resolve(string $variable)
    {
        $matches = [];

        if (!$this->isMatch($variable, $matches)) {
            throw new UnresolvedException('Variable pattern is not valid.');
        }

        $value = null;
        $resource = $matches[1];

        switch ($resource) {
            case 'task.variable':
                $task = $this->contexts[static::CONTEXT_TASK];
                $variable = $matches[2];
                $property = array_key_exists(4, $matches) ? $matches[4] : null;
                $parameters = new VariableParameters;
                $parameters->setDeserializeValues(true);
                $variables = $this->api->get('camunda.task.variable')->getList($task, $parameters);

                if (!array_key_exists($variable, $variables)) {
                    throw new UnresolvedException('Variable pattern did not resolve to data.');
                }

                $value = $variables[$variable]->getValue();

                if (null !== $property) {
                    $accessor = PropertyAccess::createPropertyAccessor();

                    try {
                        $value = $accessor->getValue($value, $property);
                    } catch (Exception $exception) {
                        throw new UnresolvedException('Variable pattern is not valid.', 0, $exception);
                    }
                }

                break;
        }

        return $value;
    }
public function resolve(string $variable)
    {
        $matches = [];

        if (!$this->isMatch($variable, $matches)) {
            throw new UnresolvedException('Variable pattern is not valid.');
        }

        $value = null;
        $resource = $matches[1];

        switch ($resource) {
            case 'task.variable':
                $task = $this->contexts[static::CONTEXT_TASK];
                $variable = $matches[2];
                $property = array_key_exists(4, $matches) ? $matches[4] : null;
                $parameters = new VariableParameters;
                $parameters->setDeserializeValues(true);
                $variables = $this->api->get('camunda.task.variable')->getList($task, $parameters);

                if (!array_key_exists($variable, $variables)) {
                    throw new UnresolvedException('Variable pattern did not resolve to data.');
                }

                $value = $variables[$variable]->getValue();

                if (null !== $property) {
                    $accessor = PropertyAccess::createPropertyAccessor();

                    try {
                        $value = $accessor->getValue($value, $property);
                    } catch (Exception $exception) {
                        throw new UnresolvedException('Variable pattern is not valid.', 0, $exception);
                    }
                }

                break;
        }

        return $value;
    }
{@inheritdoc}