Пример #1
0
 /**
  * Adds a series of filters to apply based on the key name. Unlike
  * addStaticKeyFilters, filter will only be applied on array elements.
  * The filter will be applied on all array elements instead of the array
  * itself.
  *
  * @var array Key-value pairs in which the key is the key to apply on and
  *            the value is the filter or filter name.
  */
 function addStaticKeyFiltersForArrays($filters)
 {
     require_once 'DeclFilter/StaticKeyFilterRule.php';
     $rule = new DeclFilter_StaticKeyFilterRule($filters);
     $rule->applyOnElements();
     $this->rules[] = $rule;
 }
 function testApply()
 {
     $rule = new DeclFilter_StaticKeyFilterRule(array('hello' => 'digits', 'world' => 'alpha'));
     $data = array('hello' => '123abc', 'world' => '123abc', 'foo' => '123abc');
     $rule->apply($data, 'hello');
     $rule->apply($data, 'world');
     $this->assertEquals($data['hello'], '123');
     $this->assertEquals($data['world'], 'abc');
     $this->assertEquals($data['foo'], '123abc');
 }