Check if a request is consistent (i.e. if it matches one of method's signatures)

@param array  $provided_parameters

@return int
@throws RpcException
177873
private function checkRequestConsistence(array $provided_parameters) {

        $signatures = $this->registered_method->getSignatures(false);

        $provided_parameters_count = count($provided_parameters);

        foreach ( $signatures as $num=>$signature ) {

            $requested_parameters_count = count($signature["PARAMETERS"]);

            if ( $provided_parameters_count != $requested_parameters_count ) {

                continue;

            }

            $index = 0;

            foreach ( $signature["PARAMETERS"] as $parameter => $type ) {

                if ( !Validator::validate($provided_parameters[$index], $type) ) continue 2;

                $index += 1;

            }

            return $num;

        }

        throw new RpcException("Invalid params", -32602);

    }
468633
@Override
  public boolean isSigned(int param) throws SQLException {
    checkParamIndex(param);
    return connection.getTypeInfo().isSigned(oids[param - 1]);
  }
445865
function checkParams(params, reqParams) {
    if ( reqParams.length < 1 ) {
      return;
    }

    if ( (_.isEmpty(params) || !params) && (reqParams.length > 0) ) {
      throw new Error('Missing parameters: ' + reqParams.join(', '));
    }

    var paramsKeys = _.keys(params);
  
    _.each(reqParams, function(reqParam) {
      if ( paramsKeys.indexOf(reqParam) === -1 ) {
        throw new Error('Missing parameter: ' + reqParam);
      }
    });
  }
272992
static function checkRequiredParametersAreSet(array $given, array $required)
    {
        foreach ($required as $key) {
            if (empty($given[$key])) {
                throw new MissingRequiredParameterException(
                        "Missing required parameter '$key'"
                );
            }
        }
    }
1312658
protected function verifyConditionalValuesRequirements()
    {
        if (!isset($this->requiredFieldValuesConditional)) {
            return;
        }

        $fields = $this->requiredFieldValuesConditional->getArrayCopy();

        foreach ($fields as $parentFieldName => $parentFieldDependencies) {
            if (!isset($this->$parentFieldName)) {
                continue;
            }

            foreach ($parentFieldDependencies as $parentFieldValue => $childFieldsDependency) {
                if ($this->$parentFieldName !== $parentFieldValue) {
                    continue;
                }

                $childFieldGroupValuesValidated = false;

                foreach ($childFieldsDependency as $childFieldDependency) {
                    $childFieldValuesValidated = true;

                    foreach ($childFieldDependency as $childFieldName => $childFieldValues) {
                        if ($childFieldValues instanceof RequestValidator) {
                            try {
                                $childFieldValues->run($this, $childFieldName);
                            } catch (\Genesis\Exceptions\InvalidArgument $e) {
                                $childFieldValuesValidated = false;
                            }

                            continue;
                        }

                        if (CommonUtils::isValidArray($childFieldValues)) {
                            if (!in_array($this->$childFieldName, $childFieldValues)) {
                                $childFieldValuesValidated = false;
                            }

                            continue;
                        }

                        if ($this->$childFieldName !== $childFieldValues) {
                            $childFieldValuesValidated = false;
                        }
                    }

                    if ($childFieldValuesValidated) {
                        $childFieldGroupValuesValidated = true;

                        break;
                    }
                }

                if (!$childFieldGroupValuesValidated) {
                    throw new \Genesis\Exceptions\ErrorParameter(
                        sprintf(
                            '%s with value %s is depending on group of params with specific values. ' .
                            'Please, refer to the official API documentation for %s transaction type.',
                            $parentFieldName,
                            $parentFieldValue,
                            $this->getTransactionType()
                        )
                    );
                }
            }
        }
    }
733118
public function verify()
    {
        if ($this->groupIndex < $this->sequenceIndex) {
            throw new PHPUnit_Framework_ExpectationFailedException(
              sprintf(
                "The expected invocation at method '%s' group-index %d was never reached.",

                $this->method,
                $this->sequenceIndex
              )
            );
        }
    }
327924
private function checkResultParameters(array $parameters)
    {
        $requiredParameters = [
            'payment_status',
        ];

        foreach ($requiredParameters as $requiredParameter) {
            if (!isset($parameters[$requiredParameter])) {
                throw new ParameterNotReceivedException($requiredParameter);
            }
        }
    }
259881
private function matchRequestMethod(
        string $method = null,
        array $supported = null
    ) {
        if ($supported && !in_array($method, $supported)) {
            return false;
        }

        return true;
    }
322995
private function checkRequired()
    {
        // Loop through all params
        foreach ($this->params as $param) {
            if (array_key_exists('required', $param) && $param['required'] == true) {
                if (!array_key_exists($param['name'], $this->pinputs)) {
                    throw new \Exception('Parameter "' . $param['name'] . '" is required');
                }
            }
        }

        // Loop through all options
        foreach ($this->options as $key => $option) {
            // if option is required
            if (array_key_exists('required', $option) && $option['required'] == true) {
                // check that it is defined in pinputs
                if ($this->pinputs[$option['short']] == false) {
                    throw new \Exception('Option "' . $option['help'] . '" is required');
                }
            }
        }

    }
234402
public function query($method, array $params = [])
    {
        $rpc = $this->get();
        if (null === $rpc) {
            throw new RPCException(
                "No JsonRPCInterface instances available in the pool."
            );
        }

        return $rpc->query($method, $params);
    }
334785
public function check(
        StatementsSource $source,
        CodeLocation $code_location,
        array $suppressed_issues,
        array $phantom_classes = [],
        $inferred = true
    ) {
        if ($this->checked) {
            return;
        }

        $all_good = true;

        foreach ($this->types as $atomic_type) {
            if ($atomic_type->check(
                $source,
                $code_location,
                $suppressed_issues,
                $phantom_classes,
                $inferred
            ) === false) {
                $all_good = false;
            }
        }

        if (!$all_good) {
            return false;
        } else {
            $this->checked = true;
        }
    }
484231
static function checkRequiredParameters(array $given, array $required)
    {
        foreach ($required as $key) {
            if (!array_key_exists($key, $given)) {
                throw new MissingRequiredParameterException(
                        "Missing required parameter '$key'"
                );
            }
        }
    }
272649
public function verify()
    {
        if ($this->currentIndex < $this->sequenceIndex) {
            throw new PHPUnit_Framework_ExpectationFailedException(
              sprintf(
                "The expected invocation at method '%s' index %d was never reached.",

                $this->method,
                $this->sequenceIndex
              )
            );
        }
    }
690388
public function match(
        /*# string */ $httpMethod,
        /*# string */ $uriPath,
        array $parameters = []
    )/*# :  bool */ {
        $this->initResult($httpMethod, $uriPath);
        $this->getResult()->setParameters($parameters);

        $param = ['result' => $this->result];
        if ($this->trigger(self::EVENT_BEFORE_MATCH, $param) &&
            $this->matchWithCollectors() &&
            $this->trigger(self::EVENT_AFTER_MATCH, $param)
        ) {
            return true;
        }
        return false;
    }
333017
protected function assertParametersAreValid(array $parameters, array $requiredParameters)
    {
        foreach ($requiredParameters as $parameter) {
            if (empty($parameters[$parameter])) {
                throw RequiredParameterMissingException::withParameter($parameter);
            }
        }
    }
595544
protected function matchCache()
    {
        // check if we can find a match in cache
        // check if a cache exists
        if ($this->cache instanceof Cache) {
            // check if we have any routes saved in cache
            if ($cachedRoutes = $this->cache->get('routeMiddlewareRoutes')) {
                // check if the requested uri can be found in the cache
                if (isset($cachedRoutes[$this->requestUri])) {

                    // check if endpoint class exists
                    if (!$this->endpointExists($cachedRoutes[$this->requestUri]['matchedEndpoint'])) {
                        throw new NotFound();
                    }

                    if (!$this->endpointMethodExists(
                        $cachedRoutes[$this->requestUri]['matchedEndpoint'],
                        $this->requestMethod
                    )) {
                        // route found but method can't be found
                        throw new MethodNotAllowed();
                    }

                    // match found, set info
                    $this->matchedRoute = $cachedRoutes[$this->requestUri]['matchedRoute'];
                    $this->matchedEndpoint = $cachedRoutes[$this->requestUri]['matchedEndpoint'];
                    $this->matchedMethod  = $this->requestMethod;
                    $this->params  = (isset($cachedRoutes[$this->requestUri]['params'])) ?
                        $cachedRoutes[$this->requestUri]['params'] : [];

                    // no need to look for more
                    return true;
                }
            }
        }

        return false;
    }
759703
private function checkResultParameters(array $parameters)
    {
        $elementsMissing = array_diff([
            'Ds_Date',
            'Ds_Hour',
            'Ds_Amount',
            'Ds_Currency',
            'Ds_Order',
            'Ds_MerchantCode',
            'Ds_Terminal',
            'Ds_Signature',
            'Ds_Response',
            'Ds_TransactionType',
            'Ds_SecurePayment',
            'Ds_Card_Country',
            'Ds_AuthorisationCode',
            'Ds_ConsumerLanguage',
        ], $parameters);

        if (!empty($elementsMissing)) {
            throw new ParameterNotReceivedException(
                implode(', ', $elementsMissing)
            );
        }
    }