Completed
Push — master ( af7c86...2260a0 )
by Kazi Mainuddin
03:11
created

Nexmo::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Tzsk\Sms\Drivers;
4
5
use Nexmo\Message\Text;
6
use Nexmo\Application\Client;
7
use Tzsk\Sms\Abstracts\Driver;
8
use Nexmo\Client\Credentials\Basic;
9
10
class Nexmo extends Driver
11
{
12
    /**
13
         * Settings.
14
         *
15
         * @var object
16
         */
17
    protected $settings;
18
19
    /**
20
     * Client.
21
     *
22
     * @var Client
23
     */
24
    protected $client;
25
26
    /**
27
     * Construct the class with the relevant settings.
28
     *
29
     * SendSmsInterface constructor.
30
     * @param $settings object
31
     */
32
    public function __construct($settings)
33
    {
34
        $this->settings = (object) $settings;
35
        $this->client = new Client(
36
            new Basic($this->settings->key, $this->settings->secret)
1 ignored issue
show
Unused Code introduced by
The call to Client::__construct() has too many arguments starting with new \Nexmo\Client\Creden...this->settings->secret).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
37
        );
38
    }
39
40
    /**
41
     * Send text message and return response.
42
     *
43
     * @return object
44
     */
45
    public function send()
46
    {
47
        $response = collect();
48
        foreach ($this->recipients as $recipient) {
49
            $text = new Text($recipient, $this->settings->from, $this->body);
50
            $response->put($recipient, $this->client->message()->send($text));
1 ignored issue
show
Bug introduced by
The method message() does not seem to exist on object<Nexmo\Application\Client>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
51
        }
52
53
        return (count($this->recipients) == 1) ? $response->first() : $response;
54
    }
55
}
56