Conditions | 6 |
Paths | 32 |
Total Lines | 31 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 18 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
26 | 21 | public function toArray(): array |
|
27 | { |
||
28 | 21 | $resource = []; |
|
29 | 21 | $identification = $this->getIdentification(); |
|
30 | 21 | if ($identification !== null) { |
|
31 | 18 | $resource = $identification; |
|
32 | } |
||
33 | |||
34 | 21 | if (isset($this->attributes)) { |
|
35 | 18 | $resource[Members::ATTRIBUTES] = $this->attributes; |
|
36 | } |
||
37 | 21 | if (isset($this->meta)) { |
|
38 | 15 | $resource[Members::META] = $this->meta; |
|
39 | } |
||
40 | 21 | if (isset($this->links)) { |
|
41 | 12 | $resource[Members::LINKS] = $this->links; |
|
42 | } |
||
43 | 21 | if (isset($this->relationships)) { |
|
44 | 15 | $resource[Members::RELATIONSHIPS] = array_map( |
|
45 | /** |
||
46 | * @param RelationshipFactory $relationship |
||
47 | * @return array |
||
48 | */ |
||
49 | 15 | function ($relationship) { |
|
50 | 15 | return $relationship->toArray(); |
|
51 | 15 | }, |
|
52 | 15 | $this->relationships |
|
53 | ); |
||
54 | } |
||
55 | |||
56 | 21 | return $resource; |
|
57 | } |
||
73 |