| Conditions | 4 |
| Paths | 5 |
| Total Lines | 30 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 48 | public function send($recipient, $params) |
||
| 49 | { |
||
| 50 | $params = array_merge([ |
||
| 51 | 'action' => 'message_send', |
||
| 52 | 'username' => $this->login, |
||
| 53 | 'password' => $this->secret, |
||
| 54 | 'from' => $this->sender, |
||
| 55 | 'to' => $recipient, |
||
| 56 | ], $params); |
||
| 57 | |||
| 58 | |||
| 59 | try { |
||
| 60 | $request = $this->httpClient->get( |
||
| 61 | $this->apiUrl, |
||
| 62 | [ |
||
| 63 | 'query' => $params |
||
| 64 | ] |
||
| 65 | ); |
||
| 66 | |||
| 67 | $response = json_decode($request->getBody(), true); |
||
| 68 | |||
| 69 | if ( ! isset($response['status']) || $response['status'] != 1) { |
||
| 70 | throw new DomainException($response['message'], $response['status']); |
||
| 71 | } |
||
| 72 | |||
| 73 | return $response; |
||
| 74 | } catch (DomainException $exception) { |
||
| 75 | throw CouldNotSendNotification::serviceRespondedWithAnError($exception); |
||
| 76 | } |
||
| 77 | } |
||
| 78 | } |
||
| 79 |