@param string $method
@param array $inherentParams

@return mixed

@throws \InvalidArgumentException
2905
public function injection($method, $inherentParams=[])
    {
        if (! $this->reflection->hasMethod($method)) {
            throw new \InvalidArgumentException('Method not exists.');
        }
        $instances = $this->dependentService->getParams($this->reflection, $method, count($inherentParams));
        $params = array_merge($instances, $inherentParams);
        $closure = $this->getClosure($method);
        return call_user_func_array($closure, $params);
    }
650483
protected function filterMethod($method)
    {
        if ($method === null) {
            return $method;
        }

        if (!is_string($method)) {
            throw new \InvalidArgumentException(
                sprintf(
                    'Unsupported HTTP method; must be a string, received %s',
                    is_object($method) ? get_class($method) : gettype($method)
                )
            );
        }

        $method = strtoupper($method);

        if (!in_array($method, self::$validMethods)) {
            throw new \InvalidArgumentException(sprintf('Invalid HTTP method "%s" provided', $method));
        }

        return $method;
    }
749366
public function withMethod($method)
    {
        $method = strtoupper($method);

        if (false === in_array($method, ['GET', 'HEAD', 'POST', 'PUT', 'OPTIONS', 'DELETE'])) {
            throw new \InvalidArgumentException(
                sprintf('Invalid HTTP method: %s', $method)
            );
        }

        return $this->_clone('method', $method);
    }
246971
public function invocations(string $method): Invocations
    {
        if (empty($method)) {
            throw new \InvalidArgumentException(
                    'Please provide a method name to retrieve invocations for.'
            );
        }

        if (!isset($this->_allowedMethods[$method])) {
            throw new \InvalidArgumentException(
                    $this->canNot('retrieve invocations for', $method)
            );
        }

        if (!isset($this->invocations[$method])) {
            $this->invocations[$method] = new Invocations(
                    $this->completeNameOf($method),
                    $this->_methodParams[$method]
            );
        }

        return $this->invocations[$method];
    }
151885
private function invokeClassMethod($class, $method, $namedParams, $classParams)
    {
        if (!class_exists($class)) {
            throw new \InvalidArgumentException("Class $class does not exist.");
        }

        $object = new $class();

        return $this->invokeObjectMethod($object, $method, $namedParams, $classParams);
    }
743210
public function getMethodAnnotations($method)
    {
        if (!$this->hasMethod($method)) {
            $name = $this->_getReflection()->getName();
            throw new Exception\InvalidArgumentException(
                "The class {$name} doesn't have a property called {$method}"
            );
        }

        if (empty($this->_annotations['methods'][$method])) {
            $comment = $this->_getReflection()
                ->getMethod($method)
                ->getDocComment();
            $data = AnnotationParser::getAnnotations($comment);
            $methodAnnotations = new AnnotationsList();
            foreach ($data as $property => $parsedData) {
                $methodAnnotations->append(
                    $this->_createAnnotation($property, $parsedData)
                );
            }
            $this->_annotations['methods'][$method] = $methodAnnotations;
        }
        return $this->_annotations['methods'][$method];
    }
143175
protected function getSupportedParams($method)
    {
        $columns = [];

        if ($this->isEloquentBuilder()) {
            $model = $this->getHandler()->getModel();
            $columns = in_array(ApiHelper::class, class_uses($model))
                ? $model->$method()
                : $model->getFillable();
        }

        return $columns;
    }
603708
private static function getMethodClass($method)
    {
        if (self::isAlgorithmSupported($method)) {
            return self::getSupportedMethods()[$method];
        }
        throw new \InvalidArgumentException(sprintf('Compression method "%s" is not supported.', $method));
    }
181370
private function extract(string $method, array $arguments)
    {
        try {
            $serializedArguments = serialize($arguments);
        } catch (\Exception $exception) {
            // If arguments are not serializable, skip the cache
            return $this->propertyInfoExtractor->{$method}(...$arguments);
        }

        // Calling rawurlencode escapes special characters not allowed in PSR-6's keys
        $encodedMethod = \rawurlencode($method);
        if (\array_key_exists($encodedMethod, $this->arrayCache) && \array_key_exists($serializedArguments, $this->arrayCache[$encodedMethod])) {
            return $this->arrayCache[$encodedMethod][$serializedArguments];
        }

        $item = $this->cacheItemPool->getItem($encodedMethod);

        $data = $item->get();
        if ($item->isHit()) {
            $this->arrayCache[$encodedMethod] = $data[$encodedMethod];
            // Only match if the specific arguments have been cached.
            if (\array_key_exists($serializedArguments, $data[$encodedMethod])) {
                return $this->arrayCache[$encodedMethod][$serializedArguments];
            }
        }

        // It's possible that the method has been called, but with different
        // arguments, in which case $data will already be initialized.
        if (!$data) {
            $data = [];
        }

        $value = $this->propertyInfoExtractor->{$method}(...$arguments);
        $data[$encodedMethod][$serializedArguments] = $value;
        $this->arrayCache[$encodedMethod][$serializedArguments] = $value;
        $item->set($data);
        $this->cacheItemPool->save($item);

        return $this->arrayCache[$encodedMethod][$serializedArguments];
    }
855144
public function getParams($reflectionClass, $method, $inherentNumber = 0)
    {
        $instances = [];
        if (!$reflectionClass->hasMethod($method)) {
            return $instances;
        }

        $reflection = $reflectionClass->getMethod($method);
        $reflectionParameters = $this->getReflectionParameters($reflection, $inherentNumber);

        foreach($reflectionParameters as $reflectionParameter) {
            $instances[] = $this->getDependentByParameter($reflectionParameter)->getInstance();
        }
        return $instances;
    }
851954
public function call(string $method, array $parameters)
    {
        if ($this->isSingleRequest) {
            $this->units = [];
        }

        $this->units[] = new Invoke($this->generatorId->get(), $method, $parameters);

        if ($this->isSingleRequest) {
            $resultSpecifier = $this->execute(new InvokeSpec($this->units, true));

            if (!$resultSpecifier->isSingleResult()) {
                throw new InvalidResponseException();
            }

            list($result) = $resultSpecifier->getResults();

            if ($result instanceof Result) {
                /** @var Result $result */
                return $result->getResult();
            } elseif ($result instanceof Error) {
                /** @var Error $result */
                if ($this->serverErrorMode === self::ERRMODE_EXCEPTION) {
                    throw $result->getBaseException();
                }
            }

            return null;
        }

        return $this;
    }
1205373
public function getParameters($method)
    {
        //Loop through the default values for paremeters, and make the correct output string
        $params = array();
        $paramsWithDefault = array();
        foreach ($method->getParameters() as $param) {
            $paramStr = '$' . $param->getName();
            $params[] = $paramStr;
            if ($param->isOptional()) {
                $default = $param->isDefaultValueAvailable() ? $param->getDefaultValue() : null;
                if (is_bool($default)) {
                    $default = $default ? 'true' : 'false';
                } elseif (is_array($default)) {
                    $default = 'array()';
                } elseif (is_null($default)) {
                    $default = 'null';
                } elseif (is_int($default)) {
                    //$default = $default;
                } elseif (is_resource($default)) {
                    //skip to not fail
                } else {
                    $default = "'" . trim($default) . "'";
                }
                $paramStr .= " = $default";
            }
            $paramsWithDefault[] = $paramStr;
        }

        $this->params = $params;
        $this->params_with_default = $paramsWithDefault;
    }
477910
public static function call($method, $params, $url, $publickey, $oRemoteApp = null)
        {

            $response = "";
            try {
                $sOldErrorhandler = set_error_handler('Slashworks\AppBundle\Services\Api::errorHandler');

                if(!self::$_container){
                    throw new \InvalidArgumentException("Container not given...");
                }


                if (!is_scalar($method)) {
                    throw new \Exception('Method name has no scalar value');
                }

                // check
                if (is_array($params)) {
                    // no keys
                    $params = array_values($params);
                } else {
                    throw new \Exception('Params must be given as array');
                }

                // prepares the request
                $request = array(
                    'method' => $method,
                    'params' => $params,
                    'id'     => rand(1, 999)
                );
                $request = json_encode($request);


                $rsa = new \Crypt_RSA();
                $rsa->loadKey($publickey);



                $sAppPath = self::$_container->get('kernel')->getRootDir();
                $sVendorPath = $sAppPath."/../vendor/slashworks/control-bundle/src/Slashworks/";
                $sKeyPath = $sVendorPath."AppBundle/Resources/private/api/keys/server/";

                $conairKey = file_get_contents($sKeyPath . "public.key");
                $aRequest  = array(
                    'pkey' => $conairKey,
                    'data' => base64_encode($rsa->encrypt($request))
                );

                $sRequest = json_encode($aRequest);

                $headers = array(
                    'Content-Type: application/json'
                );

                if ($oRemoteApp->getApiAuthType() == "http-basic") {
                    $sUsername = $oRemoteApp->getApiAuthHttpUser();
                    $sPassword = $oRemoteApp->getApiAuthHttpPassword();
                    if (!empty($sUsername) && !empty($sPassword)) {
                        $headers[] = "Authorization: Basic " . base64_encode($oRemoteApp->getApiAuthHttpUser() . ":" . $oRemoteApp->getApiAuthHttpPassword());
                    }
                }
                $oRequest = curl_init($url);
                curl_setopt($oRequest, CURLOPT_HTTPHEADER, $headers);
                curl_setopt($oRequest, CURLOPT_TIMEOUT, 5);
                curl_setopt($oRequest, CURLOPT_POST, 1);
                curl_setopt($oRequest, CURLOPT_POSTFIELDS, $sRequest);
                curl_setopt($oRequest, CURLOPT_RETURNTRANSFER, true);
                $response    = curl_exec($oRequest);
                $iHttpStatus = curl_getinfo($oRequest, CURLINFO_HTTP_CODE);
                $error = curl_error($oRequest);
                curl_close($oRequest);

                $rawResponse = $response;

                if ($response == "") {
                    throw new \Exception("No content received for call on: ".$url);
                }
                if ($iHttpStatus === 200) {
                    $response = json_decode($response, true);

                    if (!isset($response['data'])) {
                        throw new \Exception("Invalid response format: ".htmlentities($rawResponse));
                    }

                    $privateKey = file_get_contents(__DIR__ . "/../Resources/private/api/keys/server/private.key");
                    $rsa->loadKey($privateKey);
                    $data             = base64_decode($response['data']);
                    $decoded          = $rsa->decrypt($data);
                    $response['data'] = json_decode($decoded, true);
                    if (!is_array($response['data'])) {
                        throw new \Exception("Invalid response format: ".htmlentities($rawResponse));
                    }

                    $response['data']['statuscode'] = $iHttpStatus;
                    if($iHttpStatus !== 200){
                        $response['error'] = true;
                    }


                    ApiLog::create($iHttpStatus, $oRemoteApp->getId(), $decoded);


                    restore_error_handler();

                    return $response['data'];
                } else {

                    ApiLog::create($iHttpStatus, $oRemoteApp->getId(), $response);

                    restore_error_handler();

                    return array(
                        "statuscode" => $iHttpStatus,
                        "result"     => json_encode(array(
                                                        "status"     => false,
                                                        "error"     => true,
                                                        "statuscode" => $iHttpStatus,
                                                        "message"    => $response
                                                    )
                        )
                    );
                }


            } catch (ContextErrorException $e) {

                restore_error_handler();
                ApiLog::create(-1, $oRemoteApp->getId(), $e->getMessage());


                return array(
                    "statuscode" => $iHttpStatus,
                    "result"     => json_encode(array(
                                                    "status"     => false,
                                                    "error"     => true,
                                                    "statuscode" => -1,
                                                    "message"    => $e->getMessage()
                                                )
                    )
                );
            } catch (\Exception $e) {


                restore_error_handler();
                ApiLog::create(-1, $oRemoteApp->getId(), $e->getMessage());

                return array(
                    "statuscode" => 500,
                    "result"     => json_encode(array(
                                                    "status"     => false,
                                                    "error"     => true,
                                                    "statuscode" => -1,
                                                    "message"    => $e->getMessage()
                                                )
                    )
                );
            }
        }
50874
public function createRequest($method, $url = '', array $headers = [])
    {
        if (!is_string($url)) {
            throw new InvalidArgumentException('Url parameter must be a valid string!!');
        }

        $url = new Url((isset($this->baseUrl)?$this->baseUrl->toString():'').$url);

        $request = $this->requestFactory->build($method, $url, $headers);
        $request->setClient($this);

        return $request;
    }
1073772
public function setMethod($method)
    {
        $method = (string) $method;
        if ($method === '') {
            throw new \InvalidArgumentException('$method cannot be empty');
        }

        $this->method = $method;
    }
945961
public function setMethod($method)
	{
		if ($method === null || !is_array($method) || empty($method)) {
			throw new InvalidArgumentException('No method provided');
		}

		foreach ($method as $m) {
			if (!in_array($m, array('GET','POST','PUT','PATCH','DELETE'))) {
				throw new InvalidArgumentException('Method not allowed. allowed methods: GET, POST, PUT, PATCH, DELETE');
			}
		}

		$this->method = $method;

		return $this;
	}
371956
public function invokeArgs($method, array $params)
	{
		if (
			$this->logger !== null &&
			$this->logger->isHandling(\Monolog\Logger::DEBUG)
		) {
			$methodSynopsis = $method . '(';
			foreach (array_values($params) as $index => $param) {
				if ($index > 0) {
					$methodSynopsis .= ', ';
				}
				$methodSynopsis .= var_export($param, true);
			}
			$methodSynopsis .= ')';

			$this->logger->addDebug(
				'Invoke remote object method ' . $methodSynopsis,
				array(
					 'transport' => $this->transport,
					 'method'    => $method,
					 'params'    => $params
				)
			);
		}

		$request = $this->encoder->encodeMethod($method, $params);

		$response = $this->transport->request($request);

		$result = $this->encoder->decodeResult($response);

		if (
			$this->logger !== null &&
			$this->logger->isHandling(\Monolog\Logger::DEBUG)
		) {
			$this->logger->addDebug(
				'Receive methods ' . $methodSynopsis . ' result.',
				array(
					 'transport' => $this->transport,
					 'method'    => $method,
					 'params'    => $params
				)
			);
		}

		return $result;
	}