Determines which handler is appropriate for this request.

@param bool $isCli True for CLI handlers, false otherwise.
@param array $checkParams An array parameters for the handler isAppropriate method.
@return Returns the handler to be used for the route.
499676
private function determineHandler($isCli, $checkParams)
    {
        // determine which handler should handle this path
        foreach ($this->getHandlers() as $handler) {
            if ($isCli !== $handler->isCliHandler()) {
                continue;
            }
            $callback = array($handler, 'isAppropriate');
            if (true === call_user_func_array($callback, $checkParams)) {
                return $handler;
            }
        }

        $config = Di::getDefault()->get('config');
        if ($isCli) {
            $errorMessage = 'No CLI handler registered.';
        } else {
            $errorMessage = ($config->isDebug()) ? 'No handler responded to the request.' : '';
        }
        throw new ResourceNotFoundException($errorMessage);
    }
1034496
public static function getParams()
    {
        if (static::isCLI()) {
            return null;
        }

        if (static::$params === null) {
            if (static::isGet()) {
                static::$params = new Params($_GET);
            } else {
                $body = static::getBody();
                if (is_array($body)) {
                    static::$params = new Params(array_merge($_GET, $body));
                } else {
                    static::$params = new Params($_GET);
                }
            }
        }

        return static::$params;
    }
169138
public static String orderQuery(boolean isSandbox, Map<String, String> params) {
		if (isSandbox)
			return doPost(ORDERQUERY_SANDBOXNEW_URL, params);
		return doPost(ORDERQUERY_URL, params);
	}
172233
public function request($uri,array $param, $state)
    {

        /** @var CheckoutApi_Lib_RespondObj $respond */
        $respond = CheckoutApi_Lib_Factory::getSingletonInstance('CheckoutApi_Lib_RespondObj');
        $this->setConfig($param);

        if(!isset($param['postedParam'])) {

            $param['postedParam'] = array();
        }
        $param['rawpostedParam'] = $param['postedParam'];
        $param['postedParam'] = $this->getParser()->preparePosted($param['postedParam']);

        $respondArray = null;

        if($state){
            $headers = $this->initHeader();
            $param['headers'] = $headers;

            /** @var CheckoutApi_Client_Adapter_Abstract $adapter */
            $adapter =  $this->getAdapter($this->getProcessType(),array('uri'=>$uri,'config'=>$param));

            if($adapter){
                $adapter->connect();
                $respondString = $adapter->request()->getRespond();
                $statusResponse = $adapter->getResourceInfo();
                $this->getParser()->setResourceInfo($statusResponse);
                $respond = $this->getParser()->parseToObj($respondString);

                if($respond && isset($respond['errors'])  && $respond->hasErrors()  ) {

                    /** @var CheckoutApi_Lib_ExceptionState  $exceptionStateObj */
                    $exceptionStateObj = $respond->getExceptionState();
                    $errors = $respond->getErrors()->toArray();
                    $exceptionStateObj->flushState();

                    foreach( $errors as $error) {
                        $this->throwException($error, $respond->getErrors()->toArray());
                    }
                }elseif( $respond && isset($respond['errorCode']) && $respond->hasErrorCode()) {
                    /** @var CheckoutApi_Lib_ExceptionState  $exceptionStateObj */
                    $exceptionStateObj = $respond->getExceptionState();

                    $this->throwException($respond->getMessage(),$respond->toArray() );

                }elseif($respond && $respond->getHttpStatus()!='200') {
                    $this->throwException('Gateway is temporary down',$param );
                }

                $adapter->close();
            }

        }

        return $respond;
    }
162663
public function handlers($handlers = [], $append = true)
    {
        if (!func_num_args()) {
            $checker = $this->_classes['checker'];
            return $this->_handlers + $checker::handlers();
        }
        if ($append) {
            $this->_handlers = array_merge($this->_handlers, $handlers);
        } else {
            $this->_handlers = $handlers;
        }
        return $this->handlers();
    }
785407
protected function _request( $uri, array $params = array() )
    {
        $this->_client->setUri($uri);
        $this->_client->setParameterGet($params);

        try {
            $response = $this->_client->request();
        } catch (Exception $e) {
            return null;
        }

        if ( $response->getStatus() != 200 ) {
            return false;
        }

        return $response->getBody();
    }
799418
public static function isCli()
    {
        if (defined('STDIN')) {
            return true;
        }

        if (php_sapi_name() === 'cli') {
            return true;
        }

        if (array_key_exists('SHELL', $_ENV)) {
            return true;
        }

        if (empty($_SERVER['REMOTE_ADDR']) and !isset($_SERVER['HTTP_USER_AGENT']) and count($_SERVER['argv']) > 0) {
            return true;
        }

        if (!array_key_exists('REQUEST_METHOD', $_SERVER)) {
            return true;
        }

        return false;
    }
1370173
public function open(bool $isbase = false):int
    {
        if ($this->listingRouters($isbase) == 0) {
            return (0);
        }

        $routingArray = array();
        $pattern = '/\s*/m';
        $replace = '';

        foreach ($this->routers as $file) {
            $scope = null;
            if (($router = fopen(((!$isbase) ? FEnv::get("framework.apps") :
                    FEnv::get("framework.baseapps")) . $this->appName .
                "/Routing/" . $file, "r"))) {
                if ($this->analyseMercure($router, $file, $this->appName) == 0) {
                    die();
                }
                rewind($router);
                $mercurearray = array("activity" => "", "path" => "", "name" => "", "visibility" => "private",
                    "m_allow" => "ALL", "r_parameters" => array(), "app_proprietary" => $this->appName);
                $start = 0;
                $end = 0;
                while ($listen = fgets($router, 1024)) {
                    $listen = preg_replace($pattern, $replace, $listen);

                    if ($listen === "") {
                        continue;
                    }
                    if ($listen === "route:" && $start == 0 && $end === 0) {
                        $start = 1;
                        continue;
                    } elseif ($listen === "endroute" && $start === 1 & $end === 0) {
                        $end = 1;
                        array_push($routingArray, $mercurearray);
                    } elseif ($this->strlikeInArray(trim($listen), $this->keywords)) {
                        $exline = $listen;
                        $listen = explode(':', $listen);
                        if (!in_array($listen[0], $this->keywords)) {
                            throw new Server500(new \ArrayObject(array("explain" =>
                                "Unknown keyword '$listen[0]' in $file : ".$this->appName,
                                "solution" => "Please add the correct keyword : ".json_encode($this->keywords))));
                        }
                        if (count($listen) > 1 && empty($mercurearray['r_parameters'])) {
                            $mercurearray['r_parameters'] = $this->detectParametersType($exline, $listen[0]);
                        }
                        $mercurearray[$listen[0]] = $listen[1];
                    }
                    if ($start === 1 && $end === 1) {
                        $this->checkIfKeyExist($mercurearray, $file, $this->appName);
                        $mercurearray = array("method" => "", "path" => "", "name" => "", "visibility" =>
                            "private", "m_allow" => "ALL", "r_parameters" => array(),
                            "app_proprietary" => $this->appName);
                        $start = $end = 0;
                    }
                }
                $this->close($router);
            }
        }
        
        for ($i = 0; $i < count($routingArray); $i++) {
            $routingArray[$i]['path'] = (($this->prefix == null ||
                    $this->prefix == "") ? "" : "/".$this->prefix) . $routingArray[$i]['path'];


            $method = explode('%', $routingArray[$i]['activity']);
            if (count($method) == 2) {
                $controller = $method[0];
                $function = $method[1];
                $params = $this->detectParameters($routingArray[$i]['path']);
                $container = FrameworkContainer::getInstance();
                try {
                    $classcall = "\\".$this->appName."\\Masters\\".$controller."Master";
                    $reflect = $container->get($classcall);
                } catch (\Exception $e) {
                    throw new  Server500(new \ArrayObject(array("explain" =>
                        "Cannot instanciate "."\\".$this->appName."\\Masters\\".$controller."Master => ".
                        $e->getMessage(), "solution" => "Please check your master configuration")));
                }
                if (!method_exists($reflect, $function."Activity") ||
                    !is_callable(array($reflect, $function."Activity"))) {
                    throw new Server500(new \ArrayObject(array("explain" => "Activity is not callable : '".
                        $controller.":".$function."Activity"."' from ".$this->appName, "solution" =>
                        "Please check your controller activity")));
                }
                if (!empty($params)) {
                    array_push($this->router, array("routename" =>  $routingArray[$i]['name'], "path" =>
                        $routingArray[$i]['path'], "controller" => $controller, "method" => $function .
                        "Activity", "visibility" => $routingArray[$i]['visibility'], "params" => $params,
                        "m_allow" => $this->methodAllowedTransform($routingArray[$i]['m_allow']), "r_parameters" =>
                            $routingArray[$i]['r_parameters'],
                        "app_proprietary" => $routingArray[$i]['app_proprietary']));
                } else {
                    array_push($this->router, array("routename" =>  $routingArray[$i]['name'], "path" =>
                        $routingArray[$i]['path'], "controller" => $controller, "method" => $function .
                        "Activity", "visibility" => $routingArray[$i]['visibility'], "m_allow" =>
                        $this->methodAllowedTransform($routingArray[$i]['m_allow']), "r_parameters" =>
                        $routingArray[$i]['r_parameters'], "app_proprietary" => $routingArray[$i]['app_proprietary']));
                }
            } else {
                throw new Server500(new \ArrayObject(array("explain" =>
                    "Missing delimiter '%' to detect Activity' for  ".strtoupper($routingArray[$i]['name']).
                    " route : ".$this->appName, "solution" => "Please add the correct delimiter")));
            }
        }

        return (1);
    }
209297
public static String orderRefundQuery(boolean isSandbox, Map<String, String> params) {
		if (isSandbox)
			return doPost(REFUNDQUERY_SANDBOXNEW_URL, params);
		return doPost(REFUNDQUERY_URL, params);
	}
1308227
public function confirmOrderReference(array $aRequestParameters = array())
    {
        //Set params
        $aRequestParameters['amazon_order_reference_id'] = $this->getSession()->getVariable('amazonOrderReferenceId');

        return $this->_convertResponse($this->_getAmazonClient()->confirmOrderReference($aRequestParameters));
    }
731015
static function executeCallback($callback, array $params = array()) {
    // If callback has @
    if (is_string($callback) && strpos($callback, '@') !== false) {
      // Split
      $arrCallback = explode('@', $callback);
      // Set object
      $object = class_exists($arrCallback[0]) ? (new $arrCallback[0]()) : null;
      // Set method
      $method = isset($arrCallback[0]) ? $arrCallback[0] : null;
      // Set callback
      $callback = array($object, $method);
    }
    // If not callable
    if ( ! is_callable($callback)) {
      // Throw error
      throw new InvalidCallback('Callback must be callable');
    }
    // Execute and return
    return call_user_func_array($callback, $params);
  }
1355738
private function _castInputParametersWithClosure($params) {
		$allowed_params = $this->_getAllowedParams();		
		foreach($params as $name => $value) {
			$array_idx = $name;
			$found = false;
			$found |= $this->_valueInArray($name, array_keys($allowed_params), $array_idx);
			$found |= $this->_valueInArray($this->_path . "[" . $name . "]", array_keys($allowed_params), $array_idx);
			// XML Response can't have dashes
			$found |= $this->_valueInArray(str_replace('-', '_', $name), array_keys($allowed_params), $array_idx);
			$found |= $this->_valueInArray($this->_path . "[" . str_replace('-', '_', $name) . "]", array_keys($allowed_params), $array_idx);

      if($found) {
        $closure = $allowed_params[$array_idx];
        $this->$array_idx = $closure ? $closure($value, $params) : $value;
      }
      if($array_idx == 0) {
        //print_r($params);
      }
		}
	}
993919
protected function validateHandlerOptions(
        $fromHandlers,
        $toHandlers,
        OutputInterface $output
    ) {
        foreach (['From' => $fromHandlers, 'To' => $toHandlers] as $direction => $handlers) {
            $lowerDirection = strtolower($direction);
            if (count($handlers) !== 2) {
                $output->writeln(
                    "Enter two comma separated values for the --$lowerDirection option: " .
                    "<{$lowerDirection}_metadata_handler>,<{$lowerDirection}_binarydata_handler>"
                );

                return false;
            }

            foreach (['meta' => $handlers[0], 'binary' => $handlers[1]] as $fileDataType => $handler) {
                if (!in_array($handler, array_keys(
                    $fileDataType === 'meta' ? $this->configuredMetadataHandlers : $this->configuredBinarydataHandlers
                ))) {
                    $output->writeln("$direction $fileDataType data handler '$handler' is not configured.");
                    $this->outputConfiguredHandlers($output);

                    return false;
                }
            }
        }

        if ($fromHandlers === $toHandlers) {
            $output->writeln('From and to handlers are the same. Nothing to do.');

            return false;
        }

        return true;
    }
256097
private String createHandler(TypeElement type, ExecutableElement execute, String[] paths, boolean isRest) {
        FieldSpec hostField = FieldSpec.builder(Object.class, "mHost").addModifiers(Modifier.PRIVATE).build();

        MethodSpec rootMethod = MethodSpec.constructorBuilder()
            .addModifiers(Modifier.PUBLIC)
            .addParameter(Object.class, "host")
            .addParameter(mMapping, "mapping")
            .addParameter(mAddition, "addition")
            .addParameter(boolean.class, "isRest")
            .addStatement("super(host, mapping, addition, isRest)")
            .addStatement("this.mHost = host")
            .build();

        CodeBlock.Builder handleCode = CodeBlock.builder()
            .addStatement("$T context = $T.getContext()", mContext, mAndServer)
            .addStatement("String httpPath = request.getPath()")
            .addStatement("$T httpMethod = request.getMethod()", mHttpMethod)
            .add("\n")
            .addStatement("Object converterObj = request.getAttribute($T.HTTP_MESSAGE_CONVERTER)", mRequest)
            .addStatement("$T converter = null", mConverter)
            .beginControlFlow("if (converterObj != null && converterObj instanceof $T)", mConverter)
            .addStatement("converter = ($T)converterObj", mConverter)
            .endControlFlow()
            .add("\n")
            .addStatement("$T multiRequest = null", mRequestMultipart)
            .beginControlFlow("if (request instanceof $T)", mRequestMultipart)
            .addStatement("multiRequest = ($T) request", mRequestMultipart)
            .endControlFlow()
            .add("\n")
            .addStatement("$T requestBody = null", mRequestBody)
            .beginControlFlow("if (httpMethod.allowBody())")
            .addStatement("requestBody = request.getBody()")
            .endControlFlow()
            .add("\n")
            .addStatement("$T<String, String> pathMap = getPathVariable(httpPath)", Map.class)
            .add("\n")
            .add("/** ---------- Building Parameters ---------- **/ ")
            .add("\n");

        String host = type.getQualifiedName().toString() + "#" + execute.getSimpleName().toString() + "()";
        StringBuilder paramBuild = new StringBuilder();
        List<? extends VariableElement> parameters = execute.getParameters();
        if (!parameters.isEmpty()) {
            for (int i = 0; i < parameters.size(); i++) {
                VariableElement parameter = parameters.get(i);

                TypeName typeName = TypeName.get(parameter.asType());
                if (mContext.equals(typeName)) {
                    if (paramBuild.length() > 0) paramBuild.append(", ");
                    paramBuild.append("context");
                    continue;
                }

                if (mRequest.equals(typeName)) {
                    if (paramBuild.length() > 0) paramBuild.append(", ");
                    paramBuild.append("request");
                    continue;
                }

                if (mResponse.equals(typeName)) {
                    if (paramBuild.length() > 0) paramBuild.append(", ");
                    paramBuild.append("response");
                    continue;
                }

                if (mSession.equals(typeName)) {
                    handleCode.add("\n").addStatement("$T session$L = request.getValidSession()", mSession, i);
                    if (paramBuild.length() > 0) paramBuild.append(", ");
                    paramBuild.append(String.format("session%s", i));
                    continue;
                }

                if (mRequestBody.equals(typeName)) {
                    if (paramBuild.length() > 0) paramBuild.append(", ");
                    paramBuild.append("requestBody");
                    continue;
                }

                RequestHeader requestHeader = parameter.getAnnotation(RequestHeader.class);
                if (requestHeader != null) {
                    Validate.isTrue(isBasicType(typeName),
                        "The RequestHeader annotation only supports [String, int, long, float, double, boolean] on %s.",
                        host);

                    String name = requestHeader.name();
                    if (StringUtils.isEmpty(name)) name = requestHeader.value();
                    Validate.isTrue(!StringUtils.isEmpty(name), "The name of param is null on %s.", host);

                    handleCode.add("\n").addStatement("String header$LStr = request.getHeader($S)", i, name);
                    if (requestHeader.required()) {
                        handleCode.beginControlFlow("if ($T.isEmpty(header$LStr))", mStringUtils, i)
                            .addStatement("throw new $T($S)", mHeaderMissing, name)
                            .endControlFlow();
                    } else {
                        handleCode.beginControlFlow("if ($T.isEmpty(header$LStr))", mStringUtils, i)
                            .addStatement("header$LStr = $S", i, requestHeader.defaultValue())
                            .endControlFlow();
                    }

                    createParameter(handleCode, typeName, "header", i);
                    assignmentParameter(handleCode, typeName, "header", i, "header", i);

                    if (paramBuild.length() > 0) paramBuild.append(", ");
                    paramBuild.append(String.format(Locale.getDefault(), "header%d", i));
                    continue;
                }

                CookieValue cookieValue = parameter.getAnnotation(CookieValue.class);
                if (cookieValue != null) {
                    Validate.isTrue(mString.equals(typeName), "CookieValue can only be used with [String] on %s.",
                        host);

                    String name = cookieValue.name();
                    if (StringUtils.isEmpty(name)) name = cookieValue.value();
                    Validate.notEmpty(name, "The name of cookie is null on %s.", host);

                    handleCode.add("\n").addStatement("String cookie$L = request.getCookieValue($S)", i, name);
                    if (cookieValue.required()) {
                        handleCode.beginControlFlow("if ($T.isEmpty(cookie$L))", mStringUtils, i)
                            .addStatement("throw new $T($S)", mCookieMissing, name)
                            .endControlFlow();
                    }

                    if (paramBuild.length() > 0) paramBuild.append(", ");
                    paramBuild.append(String.format(Locale.getDefault(), "cookie%d", i));
                    continue;
                }

                PathVariable pathVariable = parameter.getAnnotation(PathVariable.class);
                if (pathVariable != null) {
                    Validate.isTrue(isBasicType(typeName),
                        "The PathVariable annotation only supports [String, int, long, float, double, boolean] on %s.",
                        host);

                    String name = pathVariable.name();
                    if (StringUtils.isEmpty(name)) name = pathVariable.value();
                    Validate.isTrue(!StringUtils.isEmpty(name), "The name of path is null on %s.", host);

                    boolean isBlurred = false;
                    for (String path : paths) {
                        if (path.matches(PATH_BLURRED) && !path.matches(PATH)) {
                            isBlurred = true;
                        }
                    }
                    Validate.isTrue(isBlurred,
                        "The PathVariable annotation must have a blurred path, for example [/project/{name}]. The " +
                            "error occurred on %s.", host);

                    handleCode.add("\n").addStatement("String path$LStr = pathMap.get($S)", i, name);

                    if (pathVariable.required()) {
                        handleCode.beginControlFlow("if ($T.isEmpty(path$LStr))", mStringUtils, i)
                            .addStatement("throw new $T($S)", mPathMissing, name)
                            .endControlFlow();
                    } else {
                        handleCode.beginControlFlow("if ($T.isEmpty(path$LStr))", mStringUtils, i)
                            .addStatement("path$LStr = $S;", i, pathVariable.defaultValue())
                            .endControlFlow();
                    }

                    createParameter(handleCode, typeName, "path", i);
                    assignmentParameter(handleCode, typeName, "path", i, "path", i);

                    if (paramBuild.length() > 0) paramBuild.append(", ");
                    paramBuild.append(String.format(Locale.getDefault(), "path%d", i));
                    continue;
                }

                QueryParam queryParam = parameter.getAnnotation(QueryParam.class);
                if (queryParam != null) {
                    Validate.isTrue(isBasicType(typeName),
                        "The QueryParam annotation only supports [String, int, long, float, double, " +
                            "boolean] on %s.", host);

                    String name = queryParam.name();
                    if (StringUtils.isEmpty(name)) name = queryParam.value();
                    Validate.isTrue(!StringUtils.isEmpty(name), "The name of param is null on %s.", host);

                    handleCode.add("\n").addStatement("String param$LStr = request.getQuery($S)", i, name);
                    if (queryParam.required()) {
                        handleCode.beginControlFlow("if ($T.isEmpty(param$LStr))", mStringUtils, i)
                            .addStatement("throw new $T($S)", mParamMissing, name)
                            .endControlFlow();
                    } else {
                        handleCode.beginControlFlow("if ($T.isEmpty(param$LStr))", mStringUtils, i)
                            .addStatement("param$LStr = $S", i, queryParam.defaultValue())
                            .endControlFlow();
                    }

                    createParameter(handleCode, typeName, "param", i);
                    assignmentParameter(handleCode, typeName, "param", i, "param", i);

                    if (paramBuild.length() > 0) paramBuild.append(", ");
                    paramBuild.append(String.format(Locale.getDefault(), "param%d", i));
                    continue;
                }

                RequestParam requestParam = parameter.getAnnotation(RequestParam.class);
                if (requestParam != null) {
                    boolean valid = mMultipart.equals(typeName) || isBasicType(typeName);
                    Validate.isTrue(valid,
                        "The RequestParam annotation only supports [MultipartFile, String, int, long, float, double, " +
                            "boolean] on %s.", host);

                    String name = requestParam.name();
                    if (StringUtils.isEmpty(name)) name = requestParam.value();
                    Validate.isTrue(!StringUtils.isEmpty(name), "The name of param is null on %s.", host);

                    handleCode.add("\n");
                    if (mMultipart.equals(typeName)) {
                        handleCode.addStatement("$T param$L = null", mMultipart, i)
                            .beginControlFlow("if (multiRequest != null)")
                            .addStatement("param$L = multiRequest.getFile($S)", i, name)
                            .endControlFlow();
                        if (requestParam.required()) {
                            handleCode.beginControlFlow("if (param$L == null)", i)
                                .addStatement("throw new $T($S)", mParamMissing, name)
                                .endControlFlow();
                        }
                    } else {
                        handleCode.addStatement("String param$LStr = request.getParameter($S)", i, name);

                        if (requestParam.required()) {
                            handleCode.beginControlFlow("if ($T.isEmpty(param$LStr))", mStringUtils, i)
                                .addStatement("throw new $T($S)", mParamMissing, name)
                                .endControlFlow();
                        } else {
                            handleCode.beginControlFlow("if ($T.isEmpty(param$LStr))", mStringUtils, i)
                                .addStatement("param$LStr = $S", i, requestParam.defaultValue())
                                .endControlFlow();
                        }

                        createParameter(handleCode, typeName, "param", i);
                        assignmentParameter(handleCode, typeName, "param", i, "param", i);
                    }

                    if (paramBuild.length() > 0) paramBuild.append(", ");
                    paramBuild.append(String.format(Locale.getDefault(), "param%d", i));
                    continue;
                }

                FormPart formPart = parameter.getAnnotation(FormPart.class);
                if (formPart != null) {
                    String name = formPart.name();
                    if (StringUtils.isEmpty(name)) name = formPart.value();
                    Validate.isTrue(!StringUtils.isEmpty(name), "The name of param is null on %s.", host);

                    handleCode.add("\n");
                    if (mMultipart.equals(typeName)) {
                        handleCode.addStatement("$T param$L = null", mMultipart, i)
                            .beginControlFlow("if (multiRequest != null)")
                            .addStatement("param$L = multiRequest.getFile($S)", i, name)
                            .endControlFlow();
                        if (formPart.required()) {
                            handleCode.beginControlFlow("if (param$L == null)", i)
                                .addStatement("throw new $T($S)", mParamMissing, name)
                                .endControlFlow();
                        }
                    } else {
                        TypeName wrapperType = ParameterizedTypeName.get(mTypeWrapper, typeName);
                        handleCode.addStatement("$T param$L = null", typeName, i)
                            .addStatement("$T param$LType = new $T(){}.getType()", Type.class, i, wrapperType)
                            .beginControlFlow("if (converter != null && multiRequest != null)")
                            .addStatement("$T param$LFile = multiRequest.getFile($S)", mMultipart, i, name)
                            .beginControlFlow("if (param$LFile != null)", i)
                            .addStatement("$T stream = param$LFile.getStream()", InputStream.class, i)
                            .addStatement("$T mimeType = param$LFile.getContentType()", mMediaType, i)
                            .addStatement("param$L = converter.convert(stream, mimeType, param$LType)", i, i)
                            .endControlFlow()
                            .beginControlFlow("if (param$L == null)", i)
                            .addStatement("String param$LStr = multiRequest.getParameter($S)", i, name)
                            .beginControlFlow("if (!$T.isEmpty(param$LStr))", mStringUtils, i)
                            .addStatement("$T stream = new $T(param$LStr.getBytes())", InputStream.class,
                                ByteArrayInputStream.class, i)
                            .addStatement("$T mimeType = $T.TEXT_PLAIN", mMediaType, mMediaType)
                            .addStatement("param$L = converter.convert(stream, mimeType, param$LType)", i, i)
                            .endControlFlow()
                            .endControlFlow()
                            .endControlFlow();

                        if (formPart.required()) {
                            handleCode.beginControlFlow("if (param$L == null)", i)
                                .addStatement("throw new $T($S)", mParamMissing, name)
                                .endControlFlow();
                        }
                    }
                    if (paramBuild.length() > 0) paramBuild.append(", ");
                    paramBuild.append(String.format(Locale.getDefault(), "param%d", i));
                    continue;
                }

                RequestBody requestBody = parameter.getAnnotation(RequestBody.class);
                if (requestBody != null) {
                    handleCode.add("\n");

                    if (mString.equals(typeName)) {
                        handleCode.addStatement("String body$L = requestBody.string()", i);
                    } else {
                        TypeName wrapperType = ParameterizedTypeName.get(mTypeWrapper, typeName);
                        handleCode.addStatement("$T body$L = null", typeName, i)
                            .beginControlFlow("if (converter != null && requestBody != null)")
                            .addStatement("$T body$LType = new $T(){}.getType()", Type.class, i, wrapperType)
                            .addStatement("$T stream = requestBody.stream()", InputStream.class)
                            .addStatement("$T mimeType = requestBody.contentType()", mMediaType)
                            .addStatement("body$L = converter.convert(stream, mimeType, body$LType)", i, i)
                            .endControlFlow();
                    }

                    if (requestBody.required()) {
                        handleCode.beginControlFlow("if (body$L == null)", i)
                            .addStatement("throw new $T()", mBodyMissing)
                            .endControlFlow();
                    }

                    if (paramBuild.length() > 0) paramBuild.append(", ");
                    paramBuild.append(String.format(Locale.getDefault(), "body%d", i));
                    continue;
                }

                throw new IllegalStateException(
                    String.format("The parameter type [%s] is not supported on %s.", typeName, host));
            }
        }

        String executeName = execute.getSimpleName().toString();
        TypeMirror returnMirror = execute.getReturnType();
        handleCode.add("\n").addStatement("Object o = null", type, executeName).beginControlFlow("try");
        if (!TypeKind.VOID.equals(returnMirror.getKind())) {
            handleCode.addStatement("o = (($T)mHost).$L($L)", type, executeName, paramBuild.toString());
        } else {
            handleCode.addStatement("(($T)mHost).$L($L)", type, executeName, paramBuild.toString());
        }
        handleCode.endControlFlow().beginControlFlow("catch (Throwable e)").addStatement("throw e").endControlFlow();
        handleCode.addStatement("return new $T($L, o)", mViewObject, isRest);

        MethodSpec handleMethod = MethodSpec.methodBuilder("handle")
            .addAnnotation(Override.class)
            .addModifiers(Modifier.PUBLIC)
            .returns(mView)
            .addParameter(mRequest, "request")
            .addParameter(mResponse, "response")
            .addException(IOException.class)
            .addCode(handleCode.build())
            .build();


        String packageName = MoreElements.getPackage(type).getQualifiedName().toString();
        executeName = StringUtils.capitalize(executeName);
        String className = String.format("%s%sHandler%s", type.getSimpleName(), executeName, "");
        int i = 0;
        while (mHashCodes.contains(className.hashCode())) {
            i++;
            className = String.format("%s%sHandler%s", type.getSimpleName(), executeName, i);
        }
        mHashCodes.add(className.hashCode());

        TypeSpec handlerClass = TypeSpec.classBuilder(className)
            .addJavadoc(Constants.DOC_EDIT_WARN)
            .addModifiers(Modifier.PUBLIC, Modifier.FINAL)
            .superclass(mMappingHandler)
            .addField(hostField)
            .addMethod(rootMethod)
            .addMethod(handleMethod)
            .build();

        JavaFile javaFile = JavaFile.builder(packageName, handlerClass).build();
        try {
            javaFile.writeTo(mFiler);
            return className;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
630340
public function canHandle(ReflectionParameter $reflectionParameter, string $url = null) : bool
    {
        $class = $reflectionParameter->getClass();
        if ($class === null) {
            return false;
        }
        $name = $class->getName();
        // Check type of requested parameter; Only interfaces are allowed in an action of a controller.
        if ($name === 'Psr\\Http\\Message\\RequestInterface' || $name === 'Psr\\Http\\Message\\ServerRequestInterface') {
            return true;
        } else {
            return false;
        }
    }
851975
public function checkHandlerRequest()
    {
        $ip = $this->getIp();
        if (!isset($_GET['method'])) {
            throw new InvalidArgumentException('Method is null');
        }

        if (!isset($_GET['params'])) {
            throw new InvalidArgumentException('Params is null');
        }

        list($method, $params) = array($_GET['method'], $_GET['params']);

        if (!in_array($method, $this->supportedPartnerMethods)) {
            throw new UnexpectedValueException('Method is not supported');
        }

        if (!isset($params['signature']) || $params['signature'] != $this->getSignature($params, $method)) {
            throw new InvalidArgumentException('Wrong signature');
        }

        /**
         * IP address check
         * @link http://help.unitpay.ru/article/67-ip-addresses
         */
        if (!in_array($ip, $this->supportedUnitpayIp)) {
            throw new InvalidArgumentException('IP address Error');
        }

        return true;
    }
674603
public function parameter($value, $isValue = false)
    {
        return $isValue ? $this->expr->literal($value) : $value;
    }