| Conditions | 4 |
| Paths | 6 |
| Total Lines | 18 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 37 | public function getPayload() |
||
| 38 | { |
||
| 39 | if (!empty($this->options)) { |
||
| 40 | $payload = array_intersect_key($this->options, array_fill_keys($this->supportedOptions, 0)); |
||
| 41 | } else { |
||
| 42 | $payload = []; |
||
| 43 | } |
||
| 44 | |||
| 45 | if (is_array($this->alert)) { |
||
| 46 | $payload += ['data' => $this->alert]; |
||
| 47 | } elseif (is_scalar($this->alert)) { |
||
| 48 | $payload += ['data' => ['message' => $this->alert]]; |
||
| 49 | } else { |
||
| 50 | throw new \RuntimeException('Invalid alert.'); |
||
| 51 | } |
||
| 52 | |||
| 53 | return json_encode($payload); |
||
| 54 | } |
||
| 55 | } |
||
| 56 |