DataFilter   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 23
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A filter() 0 13 2
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