Filter   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
dl 0
loc 47
rs 10
c 0
b 0
f 0
ccs 21
cts 24
cp 0.875
wmc 8
lcom 0
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 29 6
A getPropertyName() 0 4 1
A getDataType() 0 4 1
1
<?php
2
namespace Redbox\Hooks\Annotations;
3
4
/**
5
 * @Annotation
6
 */
7
class Filter
8
{
9
    private $propertyName;
10
    private $dataType = 'string';
11
    private $options = [];
12
    public $priority = 0;
13
14 4
    public function __construct($options = [])
15
    {
16 4
        if (isset($options['value'])) {
17 4
            $options['propertyName'] = $options['value'];
18 4
            unset($options['value']);
19 2
        }
20
21 4
        $this->priority = 10;
22
23
        $default = [
24 4
            'priority' => 10,
25 2
        ];
26
27 4
        foreach ($default as $key => $value) {
28 4
            if (isset($options[$key]) == false) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
29 4
                $options[$key] = $value;
30 2
            }
31 2
        }
32
33 4
        foreach ($options as $key => $value) {
34 4
            if (!property_exists($this, $key)) {
35
                throw new \InvalidArgumentException(sprintf('Property "%s" does not exist', $key));
36
            }
37
38 4
            $this->$key = $value;
39 2
        }
40
41 4
        $this->options = $options;
42 4
    }
43
44 4
    public function getPropertyName()
45
    {
46 4
        return $this->propertyName;
47
    }
48
49
    public function getDataType()
50
    {
51
        return $this->dataType;
52
    }
53
}
54