AbstractFilter   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 7
c 1
b 0
f 0
dl 0
loc 27
ccs 10
cts 10
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A apply() 0 3 1
A isApplicable() 0 3 1
A __construct() 0 3 1
A setAttributes() 0 5 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DevMakerLab\LaravelFilters;
6
7
use Illuminate\Database\Query\Builder;
8
9
abstract class AbstractFilter
10
{
11 5
    public function __construct(array $args = [])
12
    {
13 5
        $this->setAttributes($args);
14
    }
15
16 5
    protected function setAttributes(array $attributes): void
17
    {
18 5
        foreach (get_class_vars(static::class) as $key => $value) {
19 2
            if (isset($attributes[$key])) {
20 2
                $this->$key = $attributes[$key];
21
            }
22
        }
23
    }
24
25 1
    public static function isApplicable(... $args): bool
0 ignored issues
show
Unused Code introduced by
The parameter $args is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

25
    public static function isApplicable(/** @scrutinizer ignore-unused */ ... $args): bool

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
26
    {
27 1
        return true;
28
    }
29
30
    /**
31
     * @throws NoApplyFilterRuleException
32
     */
33 1
    public function apply(Builder $queryBuilder): void
0 ignored issues
show
Unused Code introduced by
The parameter $queryBuilder is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

33
    public function apply(/** @scrutinizer ignore-unused */ Builder $queryBuilder): void

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
34
    {
35 1
        throw new NoApplyFilterRuleException(self::class);
36
    }
37
}
38