Esempio n. 1
0
 /**
  * Check if a request is consistent (i.e. if it matches one of method's signatures)
  *
  * @param array  $provided_parameters
  *
  * @return int
  * @throws \Comodojo\Exception\RpcException
  */
 private function checkRequestConsistence($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 (!DataValidator::validate($type, $provided_parameters[$index])) {
                 continue 2;
             }
             $index += 1;
         }
         return $num;
     }
     throw new RpcException("Invalid params", -32602);
 }
Esempio n. 2
0
 /**
  * Check if a request is consistent (i.e. if it matches one of method's signatures)
  *
  * @param \Comodojo\RpcServer\RpcMethod $registered_method
  * @param array                         $parameters
  *
  * @return int
  * @throws \Comodojo\Exception\RpcException
  */
 private function checkRequestConsistence($registered_method, $parameters)
 {
     $signatures = $registered_method->getSignatures(false);
     foreach ($signatures as $num => $signature) {
         if (self::checkSignatureMatch($parameters, $signature["PARAMETERS"]) === true) {
             return $num;
         }
     }
     throw new RpcException("Invalid params", -32602);
 }