Conditions | 4 |
Paths | 7 |
Total Lines | 28 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 20 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
47 | public function send($params) |
||
48 | { |
||
49 | $base = [ |
||
50 | 'charset' => 'utf-8', |
||
51 | 'login' => $this->login, |
||
52 | 'psw' => $this->secret, |
||
53 | 'sender' => $this->sender, |
||
54 | 'fmt' => self::FORMAT_JSON, |
||
55 | ]; |
||
56 | |||
57 | $params = array_merge($base, $params); |
||
58 | |||
59 | try { |
||
60 | $response = $this->httpClient->post($this->apiUrl, ['form_params' => $params]); |
||
61 | |||
62 | $response = json_decode((string) $response->getBody(), true); |
||
63 | |||
64 | if (isset($response['error'])) { |
||
65 | throw new DomainException($response['error'], $response['error_code']); |
||
66 | } |
||
67 | |||
68 | return $response; |
||
69 | } catch (DomainException $exception) { |
||
70 | throw CouldNotSendNotification::smscRespondedWithAnError($exception); |
||
71 | } catch (\Exception $exception) { |
||
72 | throw CouldNotSendNotification::couldNotCommunicateWithSmsc($exception); |
||
73 | } |
||
74 | } |
||
75 | } |
||
76 |