Class yii\debug\components\search\Filter

Inheritanceyii\debug\components\search\Filter » yii\base\Component
Available since extension's version2.0
Source Code https://github.com/yiisoft/yii2-debug/blob/master/src/components/search/Filter.php

Provides array filtering capabilities.

Protected Properties

Hide inherited properties

Property Type Description Defined By

Public Methods

Hide inherited 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

Hide inherited properties

$rules protected property

Rules for matching filters in the way: [:fieldName => [rule1, rule2,..]]

protected array $rules = []

Method Details

Hide inherited methods

addMatcher() public method

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;
    }
}

            
filter() public method

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;
}