Conditions | 5 |
Paths | 5 |
Total Lines | 21 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 5 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
58 | 4 | public function toArray(): array |
|
59 | { |
||
60 | 4 | if ($this->status === Status::SUCCESS || $this->status === Status::FAIL) { |
|
61 | return [ |
||
62 | 2 | 'status' => $this->status, |
|
63 | 2 | 'data' => $this->data |
|
64 | ]; |
||
65 | } |
||
66 | |||
67 | $payload = [ |
||
68 | 2 | 'status' => $this->status, |
|
69 | 2 | 'message' => $this->message |
|
70 | ]; |
||
71 | 2 | if ($this->code !== null) { |
|
72 | 1 | $payload['code'] = $this->code; |
|
73 | } |
||
74 | 2 | if ($this->data !== null) { |
|
75 | 1 | $payload['data'] = $this->data; |
|
76 | } |
||
77 | |||
78 | 2 | return $payload; |
|
79 | } |
||
92 |