public function testOptionalDefaultValue()
 {
     $processor = new ParamsProcessor([new InputParam(InputParam::TYPE_POST, 'mykey10', InputParam::OPTIONAL), new InputParam(InputParam::TYPE_GET, 'mykey20', InputParam::OPTIONAL), new InputParam(InputParam::TYPE_PUT, 'mykey30', InputParam::OPTIONAL)]);
     $this->assertEquals($processor->getValues(), ['mykey10' => null, 'mykey20' => null, 'mykey30' => null]);
 }
Beispiel #2
0
 /**
  * Process input parameters
  *
  * @param ApiHandlerInterface   $handler
  *
  * @return array|bool
  */
 private function processParams(ApiHandlerInterface $handler)
 {
     $paramsProcessor = new ParamsProcessor($handler->params());
     if ($paramsProcessor->isError()) {
         $this->getHttpResponse()->setCode(Response::S500_INTERNAL_SERVER_ERROR);
         $this->sendResponse(new JsonResponse(['status' => 'error', 'message' => 'wrong input']));
         return false;
     }
     return $paramsProcessor->getValues();
 }