nextHandler = $nextHandler; $this->operationsClient = $operationsClient; $this->descriptor = $descriptor; } public function __invoke(Call $call, array $options) { $next = $this->nextHandler; return $next($call, $options)->then(function (Message $response) { $options = $this->descriptor + ['lastProtoResponse' => $response]; $operationNameMethod = $options['operationNameMethod'] ?? 'getName'; $operationName = \call_user_func([$response, $operationNameMethod]); return new OperationResponse($operationName, $this->operationsClient, $options); }); } }