Passed
Push — master ( f78f46...5cb5d8 )
by Jacques
01:56
created

SmartLoad::cancelRecharge()   B

Complexity

Conditions 3
Paths 5

Size

Total Lines 27
Code Lines 17

Duplication

Lines 27
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 27
loc 27
ccs 0
cts 14
cp 0
rs 8.8571
cc 3
eloc 17
nc 5
nop 2
crap 12
1
<?php
2
/**
3
 * SmartCall Restful API (v3) HTTP Client.
4
 *
5
 * PLEASE NOTE: The interface is very fluid while the intial integration
6
 * is taking place.  It will be refactored in the near future.
7
 *
8
 * @author    Jacques Marneweck <[email protected]>
9
 * @copyright 2017-2018 Jacques Marneweck.  All rights strictly reserved.
10
 * @license   MIT
11
 */
12
13
namespace Jacques\Smartcall\HttpClient\Traits;
14
15
trait SmartLoad
16
{
17
    /**
18
     * Authenticate and retrieves the dealer balance in Rands.
19
     *
20
     * @param string $dealerMsisdn
21
     *
22
     * @throws Exception
23
     *
24
     * @return array
25
     */
26 4 View Code Duplication
    public function balance($dealerMsisdn)
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...
27
    {
28
        try {
29 4
            $response = $this->get(
0 ignored issues
show
Bug introduced by
It seems like get() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
30 4
                sprintf(
31 4
                    '/webservice/smartload/balance/%s',
32 4
                    $dealerMsisdn
33
                ),
34
                [
35
                    'headers' => [
36 4
                        'Authorization' => $this->bearerOrBasic(),
0 ignored issues
show
Bug introduced by
It seems like bearerOrBasic() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
37
                    ],
38
                ]
39
            );
40
41
            return [
42 2
                'status'    => 'ok',
43 2
                'http_code' => $response->getStatusCode(),
44 2
                'body'      => (string) $response->getBody(),
45
            ];
46 2
        } catch (\GuzzleHttp\Exception\ClientException $e) {
47 2
            return $this->clientError($e);
0 ignored issues
show
Bug introduced by
It seems like clientError() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
48
        } catch (\GuzzleHttp\Exception\ServerException $e) {
49
            return $this->parseError($e);
0 ignored issues
show
Bug introduced by
It seems like parseError() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
50
        }
51
    }
52
53
    /**
54
     * Authenticate and request to cancel a previous recharge request. Will only
55
     * succeed if the recharge has not been successfully submitted to the network.
56
     *
57
     * @param string $dealerMsisdn
58
     * @param string $clientReference
59
     *
60
     * @throws Exception
61
     *
62
     * @return array
63
     */
64 View Code Duplication
    public function cancelRecharge($dealerMsisdn, $clientReference)
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...
65
    {
66
        try {
67
            $response = $this->delete(
0 ignored issues
show
Bug introduced by
It seems like delete() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
68
                sprintf(
69
                    '/webservice/smartload/recharges/%s/%s',
70
                    $dealerMsisdn,
71
                    $clientReference
72
                ),
73
                [
74
                    'headers' => [
75
                        'Authorization' => $this->bearerOrBasic(),
0 ignored issues
show
Bug introduced by
It seems like bearerOrBasic() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
76
                    ],
77
                ]
78
            );
79
80
            return [
81
                'status'    => 'ok',
82
                'http_code' => $response->getStatusCode(),
83
                'body'      => (string) $response->getBody(),
84
            ];
85
        } catch (\GuzzleHttp\Exception\ClientException $e) {
86
            return $this->clientError($e);
0 ignored issues
show
Bug introduced by
It seems like clientError() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
87
        } catch (\GuzzleHttp\Exception\ServerException $e) {
88
            return $this->parseError($e);
0 ignored issues
show
Bug introduced by
It seems like parseError() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
89
        }
90
    }
91
92
    /**
93
     * Authenticate and request period based cashup reports.
94
     *
95
     * @param string $dealerMsisdn
96
     * @param string $start
97
     * @param string $end
98
     *
99
     * @throws Exception
100
     *
101
     * @return array
102
     */
103 View Code Duplication
    public function cashup($dealerMsisdn, $start, $end)
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...
104
    {
105
        try {
106
            $response = $this->post(
0 ignored issues
show
Bug introduced by
It seems like post() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
107
                '/webservice/smartload/cashup',
108
                [
109
                    'headers' => [
110
                        'Authorization' => $this->bearerOrBasic(),
0 ignored issues
show
Bug introduced by
It seems like bearerOrBasic() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
111
                    ],
112
                    'json'    => [
113
                        'smartloadId' => $dealerMsisdn,
114
                        'startDate'   => $start,
115
                        'endDate'     => $end,
116
                    ],
117
                ]
118
            );
119
120
            return [
121
                'status'    => 'ok',
122
                'http_code' => $response->getStatusCode(),
123
                'body'      => (string) $response->getBody(),
124
            ];
125
        } catch (\GuzzleHttp\Exception\ClientException $e) {
126
            return $this->clientError($e);
0 ignored issues
show
Bug introduced by
It seems like clientError() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
127
        } catch (\GuzzleHttp\Exception\ServerException $e) {
128
            return $this->parseError($e);
0 ignored issues
show
Bug introduced by
It seems like parseError() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
129
        }
130
    }
131
132
    /**
133
     * Authenticate and request current day cashup report.
134
     *
135
     * @param string $dealerMsisdn
136
     *
137
     * @throws Exception
138
     *
139
     * @return array
140
     */
141 View Code Duplication
    public function cashupToday($dealerMsisdn)
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...
142
    {
143
        try {
144
            $response = $this->get(
0 ignored issues
show
Bug introduced by
It seems like get() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
145
                sprintf(
146
                    '/webservice/smartload/cashup/%s',
147
                    $dealerMsisdn
148
                ),
149
                [
150
                    'headers' => [
151
                        'Authorization' => $this->bearerOrBasic(),
0 ignored issues
show
Bug introduced by
It seems like bearerOrBasic() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
152
                    ],
153
                ]
154
            );
155
156
            return [
157
                'status'    => 'ok',
158
                'http_code' => $response->getStatusCode(),
159
                'body'      => (string) $response->getBody(),
160
            ];
161
        } catch (\GuzzleHttp\Exception\ClientException $e) {
162
            return $this->clientError($e);
0 ignored issues
show
Bug introduced by
It seems like clientError() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
163
        } catch (\GuzzleHttp\Exception\ServerException $e) {
164
            return $this->parseError($e);
0 ignored issues
show
Bug introduced by
It seems like parseError() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
165
        }
166
    }
167
168
    /**
169
     * Authenticate and request to transfer funds from one Smartload account to another.
170
     *
171
     * @param string $fromDealerMsisdn
172
     * @param string $toDealerMsisdn
173
     * @param string $amount
174
     * @param string $sendSms
175
     *
176
     * @throws Exception
177
     *
178
     * @return array
179
     */
180 3 View Code Duplication
    public function fundstransfer($fromDealerMsisdn, $toDealerMsisdn, $amount, $sendSms)
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...
181
    {
182
        try {
183 3
            $response = $this->post(
0 ignored issues
show
Bug introduced by
It seems like post() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
184 3
                '/webservice/smartload/fundstransfer',
185
                [
186
                    'headers' => [
187 3
                        'Authorization' => $this->bearerOrBasic(),
0 ignored issues
show
Bug introduced by
It seems like bearerOrBasic() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
188
                    ],
189
                    'json' => [
190 3
                        'sourceSmartloadId'    => $fromDealerMsisdn,
191 3
                        'recipientSmartloadId' => $toDealerMsisdn,
192 3
                        'amount'               => $amount,
193 3
                        'sendSms'              => $sendSms,
194
                    ],
195
                ]
196
            );
197
198
            return [
199 2
                'status'    => 'ok',
200 2
                'http_code' => $response->getStatusCode(),
201 2
                'body'      => (string) $response->getBody(),
202
            ];
203 1
        } catch (\GuzzleHttp\Exception\ClientException $e) {
204 1
            return $this->clientError($e);
0 ignored issues
show
Bug introduced by
It seems like clientError() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
205
        } catch (\GuzzleHttp\Exception\ServerException $e) {
206
            return $this->parseError($e);
0 ignored issues
show
Bug introduced by
It seems like parseError() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
207
        }
208
    }
209
210
    /**
211
     * Authenticate and retrieves a list of all available networks.
212
     *
213
     * @throws Exception
214
     *
215
     * @return array
216
     */
217 2 View Code Duplication
    public function network($id)
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...
218
    {
219
        try {
220 2
            $response = $this->get(
0 ignored issues
show
Bug introduced by
It seems like get() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
221 2
                sprintf(
222 2
                    '/webservice/smartload/networks/%d',
223 2
                    $id
224
                ),
225
                [
226
                    'headers' => [
227 2
                        'Authorization' => $this->bearerOrBasic(),
0 ignored issues
show
Bug introduced by
It seems like bearerOrBasic() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
228
                    ],
229
                ]
230
            );
231
232
            return [
233 1
                'status'    => 'ok',
234 1
                'http_code' => $response->getStatusCode(),
235 1
                'body'      => (string) $response->getBody(),
236
            ];
237 1
        } catch (\GuzzleHttp\Exception\ClientException $e) {
238 1
            return $this->clientError($e);
0 ignored issues
show
Bug introduced by
It seems like clientError() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
239
        } catch (\GuzzleHttp\Exception\ServerException $e) {
240
            return $this->parseError($e);
0 ignored issues
show
Bug introduced by
It seems like parseError() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
241
        }
242
    }
243
244
    /**
245
     * Authenticate and retrieves a list of all available networks.
246
     *
247
     * @throws Exception
248
     *
249
     * @return array
250
     */
251 2 View Code Duplication
    public function networks()
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...
252
    {
253
        try {
254 2
            $response = $this->get(
0 ignored issues
show
Bug introduced by
It seems like get() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
255 2
                '/webservice/smartload/networks',
256
                [
257
                    'headers' => [
258 2
                        'Authorization' => $this->bearerOrBasic(),
0 ignored issues
show
Bug introduced by
It seems like bearerOrBasic() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
259
                    ],
260
                ]
261
            );
262
263
            return [
264 1
                'status'    => 'ok',
265 1
                'http_code' => $response->getStatusCode(),
266 1
                'body'      => (string) $response->getBody(),
267
            ];
268 1
        } catch (\GuzzleHttp\Exception\ClientException $e) {
269 1
            return $this->clientError($e);
0 ignored issues
show
Bug introduced by
It seems like clientError() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
270
        } catch (\GuzzleHttp\Exception\ServerException $e) {
271
            return $this->parseError($e);
0 ignored issues
show
Bug introduced by
It seems like parseError() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
272
        }
273
    }
274
275
    /**
276
     * Authenticate and recharge prevend request.
277
     *
278
     * @param string $dealerMsisdn
0 ignored issues
show
Bug introduced by
There is no parameter named $dealerMsisdn. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
279
     * @param string $clientReference
0 ignored issues
show
Bug introduced by
There is no parameter named $clientReference. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
280
     * @param string $smsRecipientMsisdn
0 ignored issues
show
Bug introduced by
There is no parameter named $smsRecipientMsisdn. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
281
     * @param string $deviceId
0 ignored issues
show
Bug introduced by
There is no parameter named $deviceId. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
282
     * @param int    $productId
0 ignored issues
show
Bug introduced by
There is no parameter named $productId. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
283
     * @param int    $amount
0 ignored issues
show
Bug introduced by
There is no parameter named $amount. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
284
     * @param bool   $pinless
0 ignored issues
show
Bug introduced by
There is no parameter named $pinless. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
285
     * @param bool   $sendSms
0 ignored issues
show
Bug introduced by
There is no parameter named $sendSms. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
286
     *
287
     *
288
     * {
289
     * "smartloadId": "27821234567",
290
     * "clientReference": "abc123",
291
     * "smsRecipientMsisdn": "27821234567",
292
     * "deviceId": "27821234567",
293
     * "productId": 62,
294
     * "amount": 12,
295
     * "pinless": true,
296
     * "sendSms": true
297
     * }
298
     */
299
    public function prevend()
300
    {
301
        try {
302
            $response = $this->post(
0 ignored issues
show
Bug introduced by
It seems like post() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
303
                sprintf(
304
                    '/webservice/smartload/products/%d',
305
                    $id
0 ignored issues
show
Bug introduced by
The variable $id does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
306
                ),
307
                [
308
                    'headers' => [
309
                        'Authorization' => $this->bearerOrBasic(),
0 ignored issues
show
Bug introduced by
It seems like bearerOrBasic() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
310
                    ],
311
                    'json' => [
312
                        'smartloadId'        => '',
313
                        'clientReference'    => '',
314
                        'smsRecipientMsisdn' => '',
315
                        'deviceId'           => '',
316
                        'productId'          => '',
317
                        'amount'             => '',
318
                        'pinless'            => '',
319
                        'sendSms'            => '',
320
                    ],
321
                ]
322
            );
323
324
            return [
325
                'status'    => 'ok',
326
                'http_code' => $response->getStatusCode(),
327
                'body'      => (string) $response->getBody(),
328
            ];
329
        } catch (\GuzzleHttp\Exception\ClientException $e) {
330
            return $this->clientError($e);
0 ignored issues
show
Bug introduced by
It seems like clientError() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
331
        } catch (\GuzzleHttp\Exception\ServerException $e) {
332
            return $this->parseError($e);
0 ignored issues
show
Bug introduced by
It seems like parseError() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
333
        }
334
    }
335
336
    /**
337
     * Authenticate and retrieves a list of all available networks.
338
     *
339
     * @param int $id
340
     *
341
     * @throws Exception
342
     *
343
     * @return array
344
     */
345 2 View Code Duplication
    public function products($id)
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...
346
    {
347
        try {
348 2
            $response = $this->get(
0 ignored issues
show
Bug introduced by
It seems like get() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
349 2
                sprintf(
350 2
                    '/webservice/smartload/products/%d',
351 2
                    $id
352
                ),
353
                [
354
                    'headers' => [
355 2
                        'Authorization' => $this->bearerOrBasic(),
0 ignored issues
show
Bug introduced by
It seems like bearerOrBasic() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
356
                    ],
357
                ]
358
            );
359
360
            return [
361 1
                'status'    => 'ok',
362 1
                'http_code' => $response->getStatusCode(),
363 1
                'body'      => (string) $response->getBody(),
364
            ];
365 1
        } catch (\GuzzleHttp\Exception\ClientException $e) {
366 1
            return $this->clientError($e);
0 ignored issues
show
Bug introduced by
It seems like clientError() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
367
        } catch (\GuzzleHttp\Exception\ServerException $e) {
368
            return $this->parseError($e);
0 ignored issues
show
Bug introduced by
It seems like parseError() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
369
        }
370
    }
371
372
    /**
373
     * Authenticate and recharge request.
374
     *
375
     * @param string $dealerMsisdn
376
     * @param string $clientReference
377
     * @param string $smsRecipientMsisdn
378
     * @param string $deviceId
379
     * @param int    $productId
380
     * @param int    $amount
381
     * @param bool   $pinless
382
     * @param bool   $sendSms
383
     */
384 2
    public function recharge($dealerMsisdn, $clientReference, $smsRecipientMsisdn, $deviceId, $productId, $amount, $pinless, $sendSms)
385
    {
386
        try {
387 2
            $response = $this->post(
0 ignored issues
show
Bug introduced by
It seems like post() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
388 2
                '/webservice/smartload/recharges',
389
                [
390
                    'headers' => [
391 2
                        'Authorization' => $this->bearerOrBasic(),
0 ignored issues
show
Bug introduced by
It seems like bearerOrBasic() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
392
                    ],
393
                    'json' => [
394 2
                        'smartloadId'        => $dealerMsisdn,
395 2
                        'clientReference'    => $clientReference,
396 2
                        'smsRecipientMsisdn' => $smsRecipientMsisdn,
397 2
                        'deviceId'           => $deviceId,
398 2
                        'productId'          => $productId,
399 2
                        'amount'             => $amount,
400 2
                        'pinless'            => $pinless,
401 2
                        'sendSms'            => $sendSms,
402
                    ],
403
                ]
404
            );
405
406
            return [
407 1
                'status'    => 'ok',
408 1
                'http_code' => $response->getStatusCode(),
409 1
                'body'      => (string) $response->getBody(),
410
            ];
411 1
        } catch (\GuzzleHttp\Exception\ClientException $e) {
412 1
            return $this->clientError($e);
0 ignored issues
show
Bug introduced by
It seems like clientError() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
413
        } catch (\GuzzleHttp\Exception\ServerException $e) {
414
            return $this->parseError($e);
0 ignored issues
show
Bug introduced by
It seems like parseError() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
415
        }
416
    }
417
418
    /**
419
     * Authenticate and checks if the provided ID (MSISDN) is registered with Smartload.
420
     *
421
     * @param string $dealerMsisdn
422
     *
423
     * @throws Exception
424
     *
425
     * @return array
426
     */
427 3 View Code Duplication
    public function registered($dealerMsisdn)
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...
428
    {
429
        try {
430 3
            $response = $this->get(
0 ignored issues
show
Bug introduced by
It seems like get() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
431 3
                sprintf(
432 3
                    '/webservice/smartload/registered/%s',
433 3
                    $dealerMsisdn
434
                ),
435
                [
436
                    'headers' => [
437 3
                        'Authorization' => $this->bearerOrBasic(),
0 ignored issues
show
Bug introduced by
It seems like bearerOrBasic() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
438
                    ],
439
                ]
440
            );
441
442
            return [
443 2
                'status'    => 'ok',
444 2
                'http_code' => $response->getStatusCode(),
445 2
                'body'      => (string) $response->getBody(),
446
            ];
447 1
        } catch (\GuzzleHttp\Exception\ClientException $e) {
448 1
            return $this->clientError($e);
0 ignored issues
show
Bug introduced by
It seems like clientError() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
449
        } catch (\GuzzleHttp\Exception\ServerException $e) {
450
            return $this->parseError($e);
0 ignored issues
show
Bug introduced by
It seems like parseError() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
451
        }
452
    }
453
}
454