Passed
Push — master ( b97c16...98e719 )
by Dawid
04:21
created

Property::getAttributes()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 0
dl 0
loc 12
ccs 8
cts 8
cp 1
crap 3
rs 9.8666
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 14
    public function getType(): string
28
    {
29 14
        return $this->type;
30
    }
31
32 15
    public function getAttributes(): array
33
    {
34 15
        $attributes = get_object_vars($this);
35 15
        foreach ($attributes as $name => $value) {
36 15
            $method = 'get' . ucfirst($name);
37 15
            if (method_exists($this, $method)) {
38 15
                $attributes[$name] = $this->$method();
39
            }
40
        }
41 15
        unset($attributes['type'], $attributes['value'], $attributes['name']);
42
43 15
        return $attributes;
44
    }
45
}
46