Property::getAttributes()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 6
nc 3
nop 0
dl 0
loc 12
ccs 7
cts 7
cp 1
crap 3
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace Igni\Storage\Mapping\Annotation;
4
5
use Doctrine\Common\Annotations\Annotation;
6
use function get_object_vars;
7
use function method_exists;
8
use function ucfirst;
9
10
/**
11
 * @Annotation
12
 */
13
class Property extends Annotation
14
{
15
    /**
16
     * @var string
17
     */
18
    public $name;
19
20
    /**
21
     * @var string
22
     */
23
    public $type = 'text';
24
25
    public $class;
26
27
    public $readonly = false;
28
29 22
    public function getType(): string
30
    {
31 22
        return $this->type;
32
    }
33
34 23
    public function getAttributes(): array
35
    {
36 23
        $attributes = get_object_vars($this);
37 23
        foreach ($attributes as $name => $value) {
38 23
            $method = 'get' . ucfirst($name);
39 23
            if (method_exists($this, $method)) {
40 23
                $attributes[$name] = $this->$method();
41
            }
42
        }
43
        //unset($attributes['type'], $attributes['value'], $attributes['name']);
44
45 23
        return $attributes;
46
    }
47
}
48