Conditions | 3 |
Paths | 3 |
Total Lines | 20 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 3.0067 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
18 | 1 | public function toArray(): array |
|
19 | { |
||
20 | 1 | $obj = new ReflectionClass(static::class); |
|
21 | |||
22 | 1 | $attributes = [ |
|
23 | 1 | 'type' => $this->getType() |
|
24 | ]; |
||
25 | |||
26 | 1 | foreach ($obj->getProperties(ReflectionProperty::IS_PUBLIC) as $reflectionProperty) { |
|
27 | 1 | $name = $reflectionProperty->getName(); |
|
28 | 1 | $value = $this->$name ?? null; |
|
29 | |||
30 | 1 | if (is_null($value)) { |
|
31 | continue; |
||
32 | } |
||
33 | |||
34 | 1 | $attributes[$name] = $value; |
|
35 | } |
||
36 | |||
37 | 1 | return $attributes; |
|
38 | } |
||
40 |