SipgateClient::send()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace NotificationChannels\Sipgate;
4
5
use GuzzleHttp\ClientInterface as HttpClient;
6
use GuzzleHttp\Exception\GuzzleException;
7
use NotificationChannels\Sipgate\Exceptions\CouldNotSendNotification;
8
9
class SipgateClient
10
{
11
    /**
12
     * @var HttpClient
13
     */
14
    protected $http;
15
16
    /**
17
     * SipgateClient constructor.
18
     * @param  HttpClient  $http
19
     */
20 2
    public function __construct(HttpClient $http)
21
    {
22 2
        $this->http = $http;
23 2
    }
24
25
    /**
26
     * @param  SipgateMessage  $message
27
     * @throws CouldNotSendNotification
28
     */
29 2
    public function send(SipgateMessage $message)
30
    {
31
        try {
32 2
            $this->http->post('sessions/sms', ['json' => $message]);
33 1
        } catch (GuzzleException $exception) {
34 1
            throw CouldNotSendNotification::connectionFailed($exception);
35
        }
36 1
    }
37
}
38