Filter::getPropertyName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
crap 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