コード例 #1
0
ファイル: RuleTest.php プロジェクト: joy2fun/phpvs
 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
ファイル: Validator.php プロジェクト: joy2fun/phpvs
 /**
  * 非负整数
  *
  * @return Rule
  */
 public static function id()
 {
     return Rule::instance()->setup(FILTER_VALIDATE_INT, array('min_range' => 1));
 }
コード例 #3
0
ファイル: Sanitizer.php プロジェクト: joy2fun/phpvs
 /**
  * 任意字符
  *
  * @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);
     }
 }