Completed
Pull Request — master (#4)
by Simon
06:06 queued 05:12
created

SipgateClient   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 29
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A send() 0 8 2
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
    public function __construct(HttpClient $http)
21
    {
22
        $this->http = $http;
23
    }
24
25
    /**
26
     * @param  SipgateMessage  $message
27
     * @throws CouldNotSendNotification
28
     */
29
    public function send(SipgateMessage $message)
30
    {
31
        try {
32
            $this->http->post('sessions/sms', ['json' => $message->toArray()]);
33
        } catch (GuzzleException $exception) {
34
            throw CouldNotSendNotification::connectionFailed($exception);
0 ignored issues
show
Documentation introduced by
$exception is of type object<GuzzleHttp\Exception\GuzzleException>, but the function expects a object<Throwable>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
35
        }
36
    }
37
}
38