Passed
Push — master ( 712d5a...f0d0b0 )
by Jacques
01:58
created

SmartLoad   B

Complexity

Total Complexity 36

Size/Duplication

Total Lines 459
Duplicated Lines 71.9 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 72.51%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 36
c 1
b 0
f 0
lcom 0
cbo 0
dl 330
loc 459
ccs 124
cts 171
cp 0.7251
rs 8.8

12 Methods

Rating   Name   Duplication   Size   Complexity  
B balance() 26 26 3
B cashup() 28 28 3
B cashupToday() 26 26 3
B fundstransfer() 29 29 3
B network() 26 26 3
A networks() 23 23 3
B cancelRecharge() 27 27 3
B prevend() 33 33 3
B products() 26 26 3
B recharge() 33 33 3
B registered() 26 26 3
B transaction() 27 27 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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 3 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 3
            $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 3
                sprintf(
69 3
                    '/webservice/smartload/recharges/%s/%s',
70 3
                    $dealerMsisdn,
71 3
                    $clientReference
72
                ),
73
                [
74
                    'headers' => [
75 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...
76
                    ],
77
                ]
78
            );
79
80
            return [
81 1
                'status'    => 'ok',
82 1
                'http_code' => $response->getStatusCode(),
83 1
                'body'      => (string) $response->getBody(),
84
            ];
85 2
        } catch (\GuzzleHttp\Exception\ClientException $e) {
86 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...
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
279
     * @param string $clientReference
280
     * @param string $smsRecipientMsisdn
281
     * @param string $deviceId
282
     * @param int    $productId
283
     * @param int    $amount
284
     * @param bool   $pinless
285
     * @param bool   $sendSms
286
     */
287 2 View Code Duplication
    public function prevend($dealerMsisdn, $clientReference, $smsRecipientMsisdn, $deviceId, $productId, $amount, $pinless, $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...
288
    {
289
        try {
290 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...
291 2
                '/webservice/smartload/prevend',
292
                [
293
                    'headers' => [
294 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...
295
                    ],
296
                    'json' => [
297 2
                        'smartloadId'        => $dealerMsisdn,
298 2
                        'clientReference'    => $clientReference,
299 2
                        'smsRecipientMsisdn' => $smsRecipientMsisdn,
300 2
                        'deviceId'           => $deviceId,
301 2
                        'productId'          => $productId,
302 2
                        'amount'             => $amount,
303 2
                        'pinless'            => $pinless,
304 2
                        'sendSms'            => $sendSms,
305
                    ],
306
                ]
307
            );
308
309
            return [
310 1
                'status'    => 'ok',
311 1
                'http_code' => $response->getStatusCode(),
312 1
                'body'      => (string) $response->getBody(),
313
            ];
314 1
        } catch (\GuzzleHttp\Exception\ClientException $e) {
315 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...
316
        } catch (\GuzzleHttp\Exception\ServerException $e) {
317
            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...
318
        }
319
    }
320
321
    /**
322
     * Authenticate and retrieves a list of all available networks.
323
     *
324
     * @param int $id
325
     *
326
     * @throws Exception
327
     *
328
     * @return array
329
     */
330 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...
331
    {
332
        try {
333 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...
334 2
                sprintf(
335 2
                    '/webservice/smartload/products/%d',
336 2
                    $id
337
                ),
338
                [
339
                    'headers' => [
340 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...
341
                    ],
342
                ]
343
            );
344
345
            return [
346 1
                'status'    => 'ok',
347 1
                'http_code' => $response->getStatusCode(),
348 1
                'body'      => (string) $response->getBody(),
349
            ];
350 1
        } catch (\GuzzleHttp\Exception\ClientException $e) {
351 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...
352
        } catch (\GuzzleHttp\Exception\ServerException $e) {
353
            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...
354
        }
355
    }
356
357
    /**
358
     * Authenticate and recharge request.
359
     *
360
     * @param string $dealerMsisdn
361
     * @param string $clientReference
362
     * @param string $smsRecipientMsisdn
363
     * @param string $deviceId
364
     * @param int    $productId
365
     * @param int    $amount
366
     * @param bool   $pinless
367
     * @param bool   $sendSms
368
     */
369 2 View Code Duplication
    public function recharge($dealerMsisdn, $clientReference, $smsRecipientMsisdn, $deviceId, $productId, $amount, $pinless, $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...
370
    {
371
        try {
372 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...
373 2
                '/webservice/smartload/recharges',
374
                [
375
                    'headers' => [
376 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...
377
                    ],
378
                    'json' => [
379 2
                        'smartloadId'        => $dealerMsisdn,
380 2
                        'clientReference'    => $clientReference,
381 2
                        'smsRecipientMsisdn' => $smsRecipientMsisdn,
382 2
                        'deviceId'           => $deviceId,
383 2
                        'productId'          => $productId,
384 2
                        'amount'             => $amount,
385 2
                        'pinless'            => $pinless,
386 2
                        'sendSms'            => $sendSms,
387
                    ],
388
                ]
389
            );
390
391
            return [
392 1
                'status'    => 'ok',
393 1
                'http_code' => $response->getStatusCode(),
394 1
                'body'      => (string) $response->getBody(),
395
            ];
396 1
        } catch (\GuzzleHttp\Exception\ClientException $e) {
397 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...
398
        } catch (\GuzzleHttp\Exception\ServerException $e) {
399
            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...
400
        }
401
    }
402
403
    /**
404
     * Authenticate and checks if the provided ID (MSISDN) is registered with Smartload.
405
     *
406
     * @param string $dealerMsisdn
407
     *
408
     * @throws Exception
409
     *
410
     * @return array
411
     */
412 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...
413
    {
414
        try {
415 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...
416 3
                sprintf(
417 3
                    '/webservice/smartload/registered/%s',
418 3
                    $dealerMsisdn
419
                ),
420
                [
421
                    'headers' => [
422 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...
423
                    ],
424
                ]
425
            );
426
427
            return [
428 2
                'status'    => 'ok',
429 2
                'http_code' => $response->getStatusCode(),
430 2
                'body'      => (string) $response->getBody(),
431
            ];
432 1
        } catch (\GuzzleHttp\Exception\ClientException $e) {
433 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...
434
        } catch (\GuzzleHttp\Exception\ServerException $e) {
435
            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...
436
        }
437
    }
438
439
    /**
440
     * Authenticate and retrieves the details of the transaction that was performed
441
     * by the dealer using the Client reference number.
442
     *
443
     * @param string $dealerMsisdn
444
     * @param string $clientReference
445
     */
446 4 View Code Duplication
    public function transaction($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...
447
    {
448
        try {
449 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...
450 4
                sprintf(
451 4
                    '/webservice/smartload/recharges/%s/%s',
452 4
                    $dealerMsisdn,
453 4
                    $clientReference
454
                ),
455
                [
456
                    'headers' => [
457 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...
458
                    ],
459
                ]
460
            );
461
462
            return [
463 2
                'status'    => 'ok',
464 2
                'http_code' => $response->getStatusCode(),
465 2
                'body'      => (string) $response->getBody(),
466
            ];
467 2
        } catch (\GuzzleHttp\Exception\ClientException $e) {
468 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...
469
        } catch (\GuzzleHttp\Exception\ServerException $e) {
470
            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...
471
        }
472
    }
473
}
474