/** * Uses the underlying evaluator to extract the endpoint class method * and its Validator\Validate annotation. If an annotation exists, the * validateArguments() method is called for the actual validation. * * @param string $method Method name * @param array $arguments Positional or associative argument array * @throws JsonRpc\Exception\Argument If the validation fails on any of the arguments */ private function validate($method, $arguments) { /** @var Validate $validateAnnotation */ $reader = new AnnotationReader(); $callable = $this->mapper->getCallable($method); $filledArguments = $this->mapper->getArguments($callable, $arguments); $reflectMethod = new ReflectionMethod($callable[0], $callable[1]); $validateAnnotation = $reader->getMethodAnnotation($reflectMethod, self::VALIDATE_CLASS_NAME); if ($validateAnnotation) { $this->validateArguments($filledArguments, $validateAnnotation, $reflectMethod); } }
/** * Map method name to callable and run it with the given arguments. * * @param string $method Method name * @param array $arguments Positional or associative argument array * @return mixed Return value of the callable */ public function evaluate($method, $arguments = array()) { $callable = $this->mapper->getCallable($method); $arguments = $this->mapper->getArguments($callable, $arguments); return $this->execute($callable, $arguments); }