Example #1
0
 public function apply($value)
 {
     $whitespace = $this->whitespace ? '\\s' : '';
     if ($this->unicode) {
         $this->regexp = '@[^\\p{N}.' . $whitespace . ']+@u';
     } else {
         $this->regexp = '@[^0-9.' . $whitespace . ']+@';
     }
     return parent::apply($value);
 }
Example #2
0
 public function apply($value)
 {
     $whitespace = $this->whitespace ? '\\s' : '';
     $chars = preg_quote(implode('', $this->chars), '@');
     if ($this->unicode) {
         $this->regexp = '@[^\\p{L}' . $whitespace . $chars . ']+@u';
     } else {
         $this->regexp = '@[^A-Za-z' . $whitespace . $chars . ']+@';
     }
     return parent::apply($value);
 }
 /**
  * @dataProvider provider
  */
 public function testFilter($pattern, $replacement, $in, $out)
 {
     $this->filter->setPattern($pattern);
     $this->assertSame($this->filter->getPattern(), $pattern);
     $this->filter->setReplacement($replacement);
     $this->assertSame($this->filter->getReplacement(), $replacement);
     $this->assertSame($this->filter->filter($in), $out);
 }