예제 #1
0
파일: RegexTest.php 프로젝트: bapcat/values
 public function testCheck()
 {
     $value = '/[a-z]/';
     $regex = new Regex($value);
     $this->assertTrue($regex->check(new Text('asdf')));
     $this->assertTrue($regex->check(new Text('as1df')));
 }
예제 #2
0
 public function __construct($raw)
 {
     $regex = new Regex('/^(?:[[:xdigit:]]{2}([-:]))(?:[[:xdigit:]]{2}\\1){4}[[:xdigit:]]{2}$/');
     if (!$regex->check(new Text($raw))) {
         throw new InvalidArgumentException('Expected MAC address, but got [' . var_export($raw, true) . '] instead');
     }
     $this->raw = $raw;
 }
예제 #3
0
파일: Text.php 프로젝트: bapcat/values
 /**
  * Checks if this Text object matches a regular expression
  * 
  * @param   Regex  $regex  The regex
  * 
  * @return  boolean  True if this Text object matches the regular expression, false otherwise
  */
 public function matches(Regex $regex)
 {
     return $regex->check($this);
 }