original_string: private function bindRequestParamsToClass(ServerRequestInterface $request, \ReflectionClass $reflectClass)
      {
          try {
              $object = $reflectClass->newInstance();
              $queryParams = $request->getQueryParams();
              // Get request body, auto decode when content type is json format
              if (StringHelper::startsWith($request->getHeaderLine('Content-Type'), 'application/json')) {
                  $requestBody = JsonHelper::decode($request->getBody()->getContents(), true);
              } else {
                  $requestBody = $request->getParsedBody();
              }
              // Merge query params and request body
              $requestParams = array_merge($queryParams, $requestBody);
              // Binding request params to target object
              $properties = $reflectClass->getProperties();
              foreach ($properties as $property) {
                  $name = $property->getName();
                  if (!isset($requestParams[$name])) {
                      continue;
                  }
                  if (!$property->isPublic()) {
                      $property->setAccessible(true);
                  }
                  $property->setValue($object, $requestParams[$name]);
              }
          } catch (\Exception $e) {
              $object = null;
          }
          return $object;
      }
code: private function bindRequestParamsToClass(ServerRequestInterface $request, \ReflectionClass $reflectClass)
      {
          try {
              $object = $reflectClass->newInstance();
              $queryParams = $request->getQueryParams();
              // Get request body, auto decode when content type is json format
              if (StringHelper::startsWith($request->getHeaderLine('Content-Type'), 'application/json')) {
                  $requestBody = JsonHelper::decode($request->getBody()->getContents(), true);
              } else {
                  $requestBody = $request->getParsedBody();
              }
              // Merge query params and request body
              $requestParams = array_merge($queryParams, $requestBody);
              // Binding request params to target object
              $properties = $reflectClass->getProperties();
              foreach ($properties as $property) {
                  $name = $property->getName();
                  if (!isset($requestParams[$name])) {
                      continue;
                  }
                  if (!$property->isPublic()) {
                      $property->setAccessible(true);
                  }
                  $property->setValue($object, $requestParams[$name]);
              }
          } catch (\Exception $e) {
              $object = null;
          }
          return $object;
      }
code_tokens: private function bindRequestParamsToClass ( ServerRequestInterface $ request , \ ReflectionClass $ reflectClass ) { try { $ object = $ reflectClass -> newInstance ( ) ; $ queryParams = $ request -> getQueryParams ( ) ; // Get request body, auto decode when content type is json format if ( StringHelper :: startsWith ( $ request -> getHeaderLine ( 'Content-Type' ) , 'application/json' ) ) { $ requestBody = JsonHelper :: decode ( $ request -> getBody ( ) -> getContents ( ) , true ) ; } else { $ requestBody = $ request -> getParsedBody ( ) ; } // Merge query params and request body $ requestParams = array_merge ( $ queryParams , $ requestBody ) ; // Binding request params to target object $ properties = $ reflectClass -> getProperties ( ) ; foreach ( $ properties as $ property ) { $ name = $ property -> getName ( ) ; if ( ! isset ( $ requestParams [ $ name ] ) ) { continue ; } if ( ! $ property -> isPublic ( ) ) { $ property -> setAccessible ( true ) ; } $ property -> setValue ( $ object , $ requestParams [ $ name ] ) ; } } catch ( \ Exception $ e ) { $ object = null ; } return $ object ; }
docstring: Bind request parameters to instance of ReflectClass
  
  @param ServerRequestInterface $request
  @param \ReflectionClass $reflectClass
  @return Object
docstring_tokens: Bind request parameters to instance of ReflectClass