Пример #1
0
 /**
  * Constructor
  *
  * @param  string $regexp PCRE regexp, with delimiters and modifiers, e.g. "/foo/i"
  * @return void
  */
 public function __construct($regexp, $isGlobal = false)
 {
     if (@preg_match($regexp, '') === false) {
         throw new InvalidArgumentException('Invalid regular expression ' . var_export($regexp, true));
     }
     parent::__construct($regexp);
     $this->setDynamic('JS', function () {
         return $this->toJS();
     });
     $this->regexp = $regexp;
     $this->isGlobal = $isGlobal;
 }
Пример #2
0
 /**
  * @testdox setDynamic() throws an exception on invalid callback
  * @expectedException InvalidArgumentException
  * @expectedExceptionMessage valid callback
  */
 public function testSetDynamicInvalid()
 {
     $variant = new Variant();
     $variant->setDynamic('foo', '*invalid*');
 }