Completed
Push — master ( 953e3f...307f6c )
by Simon
03:54 queued 02:56
created

SipgateClient::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Simonkub\Laravel\Notifications\Sipgate;
4
5
use GuzzleHttp\Exception\GuzzleException;
6
use GuzzleHttp\ClientInterface as HttpClient;
7
use Simonkub\Laravel\Notifications\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->toArray()]);
33 1
        } catch (GuzzleException $exception) {
34 1
            throw CouldNotSendNotification::connectionFailed($exception);
35
        }
36 1
    }
37
}
38