SMS::getMessageID()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: vincent
5
 * Date: 12/14/17
6
 * Time: 4:54 PM.
7
 */
8
9
namespace CraftedSystems\LaravelSMS;
10
11
use Illuminate\Http\Request;
0 ignored issues
show
Bug introduced by
The type Illuminate\Http\Request was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
13
class SMS
14
{
15
    /**
16
     * SMS Configuration.
17
     *
18
     * @var null|object
19
     */
20
    protected $config = null;
21
22
    /**
23
     * Sms Gateway Settings.
24
     *
25
     * @var null|object
26
     */
27
    protected $settings = null;
28
29
    /**
30
     * Sms Gateway Name.
31
     *
32
     * @var null|string
33
     */
34
    protected $gateway = null;
35
36
    /**
37
     * @var object
38
     */
39
    protected $object = null;
40
41
    /**
42
     * SMS constructor.
43
     *
44
     * @throws \Exception
45
     */
46
    public function __construct()
47
    {
48
        $this->config = config('sms');
0 ignored issues
show
Bug introduced by
The function config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

48
        $this->config = /** @scrutinizer ignore-call */ config('sms');
Loading history...
49
        $this->gateway = $this->config['default'];
50
        $this->mapGateway();
51
    }
52
53
    /**
54
     * Change the gateway on the fly.
55
     *
56
     * @param $gateway
57
     *
58
     * @return $this
59
     */
60
    public function gateway($gateway)
61
    {
62
        $this->gateway = $gateway;
63
        $this->mapGateway();
64
65
        return $this;
66
    }
67
68
    /**
69
     *map the gateway that will be used to send.
70
     */
71
    private function mapGateway()
72
    {
73
        $this->settings = $this->config['gateways'][$this->gateway];
74
        $class = $this->config['map'][$this->gateway];
75
        $this->object = new $class($this->settings);
76
    }
77
78
    /**
79
     * @param $recipient
80
     * @param $message
81
     * @param null $params
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $params is correct as it would always require null to be passed?
Loading history...
82
     *
83
     * @return mixed
84
     */
85
    public function send($recipient, $message, $params = null)
86
    {
87
        return $this->object->send($recipient, $message, $params);
88
    }
89
90
    /**
91
     * define when the a message is successfully sent.
92
     *
93
     * @return bool
94
     */
95
    public function is_successful()
96
    {
97
        return $this->object->is_successful();
98
    }
99
100
    /**
101
     * the message ID as received on the response.
102
     *
103
     * @return mixed
104
     */
105
    public function getMessageID()
106
    {
107
        return $this->object->getMessageID();
108
    }
109
110
    /**
111
     * @return mixed
112
     */
113
    public function getBalance()
114
    {
115
        return $this->object->getBalance();
116
    }
117
118
    /**
119
     * @param Request $request
120
     *
121
     * @return mixed
122
     */
123
    public function getDeliveryReports(Request $request)
124
    {
125
        return $this->object->getDeliveryReports($request);
126
    }
127
}
128