Esempio n. 1
0
 public function testHandler()
 {
     $handler = $this->getMock('\\PHPVS\\Handler');
     $handler->expects($this->exactly(2))->method('handle');
     RuleSet::attachHandler($handler);
     RuleSet::filter(["not an int", "no an email"], [Validator::int()->prepare(), Validator::email()->prepare()]);
     RuleSet::detachHandler($handler);
 }
Esempio n. 2
0
 /**
  * @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);
     }
 }