nextHandler = $nextHandler; $this->descriptor = $descriptor; } public function __invoke(Call $call, array $options) { $next = $this->nextHandler; $descriptor = $this->descriptor; return $next($call, $options)->then( function (Message $response) use ($call, $next, $options, $descriptor) { $page = new Page( $call, $options, $next, $descriptor, $response ); return new PagedListResponse($page); } ); } }