Class yii\debug\components\search\Filter
Inheritance | yii\debug\components\search\Filter » yii\base\Component |
---|---|
Available since extension's version | 2.0 |
Source Code | https://github.com/yiisoft/yii2-debug/blob/master/src/components/search/Filter.php |
Provides array filtering capabilities.
Public Methods
Method | Description | Defined By |
---|---|---|
addMatcher() | Adds data filtering rule. | yii\debug\components\search\Filter |
filter() | Applies filter on a given array and returns filtered data. | yii\debug\components\search\Filter |
Property Details
Method Details
Adds data filtering rule.
public void addMatcher ( $name, yii\debug\components\search\matchers\MatcherInterface $rule ) | ||
$name | string |
Attribute name |
$rule | yii\debug\components\search\matchers\MatcherInterface |
public function addMatcher($name, MatcherInterface $rule)
{
if ($rule->hasValue()) {
$this->rules[$name][] = $rule;
}
}
Applies filter on a given array and returns filtered data.
public array filter ( array $data ) | ||
$data | array |
Data to filter |
return | array |
Filtered data |
---|
public function filter(array $data)
{
$filtered = [];
foreach ($data as $row) {
if ($this->passesFilter($row)) {
$filtered[] = $row;
}
}
return $filtered;
}