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

Clockwork::send()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 12

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
dl 12
loc 12
rs 9.8666
c 0
b 0
f 0
cc 3
nc 4
nop 0
1
<?php
2
3
namespace Tzsk\Sms\Drivers;
4
5
use Tzsk\Sms\Abstracts\Driver;
6
use mediaburst\ClockworkSMS\Clockwork as ClockworkClient;
7
8
class Clockwork extends Driver
9
{
10
    /**
11
     * Settings.
12
     *
13
     * @var object
14
     */
15
    protected $settings;
16
17
    /**
18
     * Client.
19
     *
20
     * @var ClockworkClient
21
     */
22
    protected $client;
23
24
    /**
25
     * Construct the class with the relevant settings.
26
     *
27
     * SendSmsInterface constructor.
28
     * @param $settings object
29
     */
30
    public function __construct($settings)
31
    {
32
        $this->settings = (object) $settings;
33
        $this->client = new ClockworkClient($this->settings->key);
34
    }
35
36
    /**
37
     * Send text message and return response.
38
     *
39
     * @return object
40
     */
41 View Code Duplication
    public function send()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
42
    {
43
        $response = collect();
44
        foreach ($this->recipients as $recipient) {
45
            $response->put($recipient, $this->client->send([
46
                'to' => $recipient,
47
                'message' => $this->body,
48
            ]));
49
        }
50
51
        return (count($this->recipients) == 1) ? $response->first() : $response;
52
    }
53
}
54