Passed
Push — master ( 645444...70cdd5 )
by
unknown
05:22 queued 10s
created

FortySixElksSMS::send()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 22
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 22
rs 9.8333
cc 4
nc 2
nop 0
1
<?php
2
3
namespace NotificationChannels\FortySixElks;
4
5
use NotificationChannels\FortySixElks\Exceptions\CouldNotSendNotification;
6
7
class FortySixElksSMS extends FortySixElksMedia implements FortySixElksMediaInterface
8
{
9
    const ENDPOINT = 'https://api.46elks.com/a1/SMS';
10
    public $type = 'SMS';
11
12
    /**
13
     * FortySixElksSMS constructor.
14
     */
15
    public function __construct()
16
    {
17
        return parent::__construct();
0 ignored issues
show
Bug introduced by
Are you sure the usage of parent::__construct() targeting NotificationChannels\For...lksMedia::__construct() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
18
    }
19
20
    /**
21
     * @return $this
22
     */
23
    public function send()
24
    {
25
        try {
26
            $response = $this->client->request('POST', self::ENDPOINT, [
0 ignored issues
show
Unused Code introduced by
The assignment to $response is dead and can be removed.
Loading history...
27
                'form_params' => [
28
                    'from'     => $this->from,
29
                    'message'  => $this->getContent(),
30
                    'to'       => $this->phone_number,
31
                    'flashsms' => (isset($this->payload['flash']) && $this->payload['flash']) ? 'yes' : 'no',
32
                ],
33
34
            ]);
35
        } catch (\GuzzleHttp\Exception\BadResponseException $e) {
36
            $response = $e->getResponse();
37
38
            throw CouldNotSendNotification::serviceRespondedWithAnError(
39
                $response->getBody()->getContents(),
40
                $response->getStatusCode()
41
            );
42
        }
43
44
        return $this;
45
    }
46
47
    public function flash()
48
    {
49
        $this->payload['flash'] = true;
50
51
        return $this;
52
    }
53
}
54