push() public method

Add a handler to the stack
public push ( Tebru\Retrofit\Generation\Handler $handler )
$handler Tebru\Retrofit\Generation\Handler
コード例 #1
0
 /**
  * Handle the event
  *
  * @param MethodEvent $event
  */
 public function __invoke(MethodEvent $event)
 {
     $methodModel = $event->getMethodModel();
     $annotations = $event->getAnnotationCollection();
     $annotationProvider = new AnnotationProvider($annotations, $methodModel);
     $body = new Body();
     $stack = new HandlerStack(new HandlerContext($annotationProvider, $body, new ArrayPrinter()));
     $stack->push(new UrlHandler());
     $stack->push(new HeaderHandler());
     $stack->push(new BodyHandler());
     $stack->push(new ResponseHandler());
     $stack->push(new ReturnHandler());
     $stack->execute();
     $methodModel->setBody($body);
 }
コード例 #2
0
 public function testExecution()
 {
     $context = Mockery::mock(HandlerContext::class);
     $handler = Mockery::mock(Handler::class);
     $handler->shouldReceive('__invoke')->times(1)->with($context)->andReturn();
     $stack = new HandlerStack($context);
     $stack->push($handler);
     $stack->execute();
 }