DataFilter::filter()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 1
1
<?php
2
3
namespace yiicod\datafilter;
4
5
use yii\base\BaseObject;
6
7
/**
8
 * Class DataFilter
9
 *
10
 * @package yiicod\datafilter
11
 */
12
class DataFilter extends BaseObject
13
{
14
    /**
15
     * Filter data
16
     *
17
     * @param DataFilterAbstract $dataFilter
18
     *
19
     * @return mixed
20
     */
21
    public static function filter(DataFilterAbstract $dataFilter)
22
    {
23
        $handlers = get_class($dataFilter)::handlers($dataFilter);
0 ignored issues
show
Bug introduced by
The method handlers cannot be called on get_class($dataFilter) (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
24
25
        $data = $dataFilter;
26
        foreach ($handlers as $class) {
27
            /** @var DataHandlerInterface $handler */
28
            $handler = new $class();
29
            $data = $handler->handle($data);
30
        }
31
32
        return $data->value;
33
    }
34
}
35