FortySixElksMMS   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 17
c 1
b 0
f 0
dl 0
loc 39
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A image() 0 5 1
A send() 0 19 3
1
<?php
2
3
namespace NotificationChannels\FortySixElks;
4
5
use NotificationChannels\FortySixElks\Exceptions\CouldNotSendNotification;
6
7
class FortySixElksMMS extends FortySixElksMedia implements FortySixElksMediaInterface
8
{
9
    const ENDPOINT = 'https://api.46elks.com/a1/mms';
10
    public $type = 'MMS';
11
12
    public function __construct()
13
    {
14
        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...
15
    }
16
17
    public function image($url)
18
    {
19
        $this->payload['image'] = $url;
20
21
        return $this;
22
    }
23
24
    /**
25
     * @return $this
26
     */
27
    public function send()
28
    {
29
        try {
30
            $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...
31
                'form_params' => [
32
                    'from'     => $this->from,
33
                    'message'  => $this->getContent(),
34
                    'to'       => $this->phone_number,
35
                    'image'    => isset($this->payload['image']) ? $this->payload['image'] : null,
36
                ],
37
38
            ]);
39
        } catch (\GuzzleHttp\Exception\BadResponseException $e) {
40
            $response = $e->getResponse();
41
42
            throw CouldNotSendNotification::serviceRespondedWithAnError($response->getBody()->getContents(), $response->getStatusCode());
43
        }
44
45
        return $this;
46
    }
47
}
48