示例#1
0
 public function testPreg()
 {
     $rule = Rule::instance();
     $this->assertSame("something", $rule->preg("~^something\$~")->filter("something"));
     $this->assertNull($rule->preg("~^something~")->filter("nothing", $default = null));
 }
示例#2
0
 /**
  * 非负整数
  *
  * @return Rule
  */
 public static function id()
 {
     return Rule::instance()->setup(FILTER_VALIDATE_INT, array('min_range' => 1));
 }
示例#3
0
 /**
  * 任意字符
  *
  * @codeCoverageIgnore
  * @return Rule
  */
 public static function raw()
 {
     return Rule::instance()->setup(FILTER_UNSAFE_RAW);
 }
示例#4
0
文件: RuleSet.php 项目: joy2fun/phpvs
 /**
  * @param mixed $data
  * @param string $key
  * @param string $message
  */
 public function handle($data, $key = null, $message = '')
 {
     if (RuleSet::getHandlers() === null) {
         RuleSet::attachHandler(new Handler\Exception());
         // attach a default handler
     }
     foreach (RuleSet::getHandlers() as $handler) {
         call_user_func(array($handler, 'handle'), Rule::instance(), $data, $key, $message);
     }
 }