Issues (8)

src/FortySixElksSMS.php (2 issues)

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
11
    public $type = 'SMS';
12
    protected $flash = 'no';
13
    protected $dry = 'no';
14
    protected $whendelivered = null;
15
    protected $log = false;
16
17
    /**
18
     * FortySixElksSMS constructor.
19
     */
20
    public function __construct()
21
    {
22
        return parent::__construct();
0 ignored issues
show
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...
23
    }
24
25
    /**
26
     * @return $this
27
     */
28
    public function send()
29
    {
30
        try {
31
            $response = $this->client->request('POST', self::ENDPOINT, [
0 ignored issues
show
The assignment to $response is dead and can be removed.
Loading history...
32
                'form_params' => [
33
                    'from'          => $this->from,
34
                    'message'       => $this->getContent(),
35
                    'to'            => $this->phone_number,
36
                    'flashsms'      => $this->flash,
37
                    'dryrun'        => $this->dry,
38
                    'whendelivered' => $this->whendelivered,
39
                    'dontlog'       => $this->log ? $this->log : '',
40
                ],
41
42
            ]);
43
        } catch (\GuzzleHttp\Exception\BadResponseException $e) {
44
            $response = $e->getResponse();
45
46
            throw CouldNotSendNotification::serviceRespondedWithAnError(
47
                $response->getBody()->getContents(),
48
                $response->getStatusCode()
49
            );
50
        }
51
52
        return $this;
53
    }
54
55
    /**
56
     * @return $this
57
     */
58
    public function flash()
59
    {
60
        $this->flash = $this->payload['flash'] ?? 'yes';
61
62
        return $this;
63
    }
64
65
    /**
66
     * @return $this
67
     */
68
    public function dry()
69
    {
70
        $this->dry = $this->payload['dryrun'] ?? 'yes';
71
72
        return $this;
73
    }
74
75
    /**
76
     * @param string $url
77
     *
78
     * @return $this
79
     */
80
    public function whendelivered($url)
81
    {
82
        $this->whendelivered = $this->payload['whendelivered'] ?? $url;
83
84
        return $this;
85
    }
86
87
    /**
88
     * @return $this
89
     */
90
    public function dontLog()
91
    {
92
        $this->log = $this->payload['dontLog'] ?? 'message';
93
94
        return $this;
95
    }
96
}
97