DMS\Filter\Filters\ToLower::apply PHP Method

apply() public method

{@inheritDoc}
public apply ( Rule $rule, $value )
$rule DMS\Filter\Rules\Rule
    public function apply(Rule $rule, $value)
    {
        if ($this->useEncoding($rule)) {
            return mb_strtolower((string) $value, $rule->encoding);
        }
        return strtolower((string) $value);
    }

Usage Example

Example #1
0
 /**
  * @expectedException \DMS\Filter\Exception\FilterException
  */
 public function testInvalidEncoding()
 {
     if (!function_exists('mb_strtolower')) {
         $this->markTestSkipped('mbstring extension not enabled');
     }
     $rule = new ToLowerRule(array('encoding' => 'invalid'));
     $filter = new ToLower();
     $result = $filter->apply($rule, 'x');
 }