Esempio n. 1
0
 /**
  * Ensures that method provided exists in this class.
  *
  * @param string $name Method name.
  *
  * @return string Same method name, but validated.
  * @throws InvalidArgumentException If method name is not valid (20) or do not exists (21).
  */
 protected static function ensureMethodExists($name)
 {
     $args = ['class' => get_called_class()];
     try {
         $args['method'] = String::ensureIsValidVarName($name);
     } catch (InvalidArgumentException $error) {
         $msg = nml_msg('Method name is not valid.');
         throw new InvalidArgumentException($msg, 20, $error);
     }
     if (method_exists($args['class'], $args['method']) === false) {
         $msg = nml_msg('"{class}::{method}" do not exists.', $args);
         throw new InvalidArgumentException($msg, 21);
     }
     return $name;
 }