Passed
Push — master ( 60f89c...3e6fc7 )
by Jacques
02:01
created

SmartLoad::cashupToday()   B

Complexity

Conditions 3
Paths 5

Size

Total Lines 26
Code Lines 16

Duplication

Lines 26
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 26
loc 26
ccs 0
cts 13
cp 0
rs 8.8571
cc 3
eloc 16
nc 5
nop 1
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 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
            $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
                sprintf(
31
                    '/webservice/smartload/balance/%s',
32
                    $dealerMsisdn
33
                ),
34
                [
35
                    'headers' => [
36
                        '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
                'status'    => 'ok',
43
                'http_code' => $response->getStatusCode(),
44
                'body'      => (string) $response->getBody(),
45
            ];
46
        } catch (\GuzzleHttp\Exception\ClientException $e) {
47
            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 period based cashup reports.
55
     *
56
     * @param string $dealerMsisdn
57
     * @param string $start
58
     * @param string $end
59
     *
60
     * @throws Exception
61
     *
62
     * @return array
63
     */
64 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...
65
    {
66
        try {
67
            $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...
68
                '/webservice/smartload/cashup',
69
                [
70
                    'headers' => [
71
                        '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...
72
                    ],
73
                    'json'    => [
74
                        'smartloadId' => $dealerMsisdn,
75
                        'startDate'   => $start,
76
                        'endDate'     => $end,
77
                    ],
78
                ]
79
            );
80
81
            return [
82
                'status'    => 'ok',
83
                'http_code' => $response->getStatusCode(),
84
                'body'      => (string) $response->getBody(),
85
            ];
86
        } catch (\GuzzleHttp\Exception\ClientException $e) {
87
            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...
88
        } catch (\GuzzleHttp\Exception\ServerException $e) {
89
            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...
90
        }
91
    }
92
93
    /**
94
     * Authenticate and request current day cashup report.
95
     *
96
     * @param string $dealerMsisdn
97
     *
98
     * @throws Exception
99
     *
100
     * @return array
101
     */
102 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...
103
    {
104
        try {
105
            $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...
106
                sprintf(
107
                    '/webservice/smartload/cashup/%s',
108
                    $dealerMsisdn
109
                ),
110
                [
111
                    'headers' => [
112
                        '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...
113
                    ],
114
                ]
115
            );
116
117
            return [
118
                'status'    => 'ok',
119
                'http_code' => $response->getStatusCode(),
120
                'body'      => (string) $response->getBody(),
121
            ];
122
        } catch (\GuzzleHttp\Exception\ClientException $e) {
123
            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...
124
        } catch (\GuzzleHttp\Exception\ServerException $e) {
125
            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...
126
        }
127
    }
128
129
    /**
130
     * Authenticate and request to transfer funds from one Smartload account to another.
131
     *
132
     * @param string $fromDealerMsisdn
133
     * @param string $toDealerMsisdn
134
     * @param string $amount
135
     * @param string $sendSms
136
     *
137
     * @throws Exception
138
     *
139
     * @return array
140
     */
141 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...
142
    {
143
        try {
144
            $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...
145
                '/webservice/smartload/fundstransfer',
146
                [
147
                    'headers' => [
148
                        '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...
149
                    ],
150
                    'json' => [
151
                        'sourceSmartloadId'    => $fromDealerMsisdn,
152
                        'recipientSmartloadId' => $toDealerMsisdn,
153
                        'amount'               => $amount,
154
                        'sendSms'              => $sendSms,
155
                    ],
156
                ]
157
            );
158
159
            return [
160
                'status'    => 'ok',
161
                'http_code' => $response->getStatusCode(),
162
                'body'      => (string) $response->getBody(),
163
            ];
164
        } catch (\GuzzleHttp\Exception\ClientException $e) {
165
            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...
166
        } catch (\GuzzleHttp\Exception\ServerException $e) {
167
            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...
168
        }
169
    }
170
171
    /**
172
     * Authenticate and retrieves a list of all available networks.
173
     *
174
     * @throws Exception
175
     *
176
     * @return array
177
     */
178 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...
179
    {
180
        try {
181 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...
182 2
                sprintf(
183 2
                    '/webservice/smartload/networks/%d',
184 2
                    $id
185
                ),
186
                [
187
                    'headers' => [
188 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...
189
                    ],
190
                ]
191
            );
192
193
            return [
194 1
                'status'    => 'ok',
195 1
                'http_code' => $response->getStatusCode(),
196 1
                'body'      => (string) $response->getBody(),
197
            ];
198 1
        } catch (\GuzzleHttp\Exception\ClientException $e) {
199 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...
200
        } catch (\GuzzleHttp\Exception\ServerException $e) {
201
            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...
202
        }
203
    }
204
205
    /**
206
     * Authenticate and retrieves a list of all available networks.
207
     *
208
     * @throws Exception
209
     *
210
     * @return array
211
     */
212 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...
213
    {
214
        try {
215 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...
216 2
                '/webservice/smartload/networks',
217
                [
218
                    'headers' => [
219 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...
220
                    ],
221
                ]
222
            );
223
224
            return [
225 1
                'status'    => 'ok',
226 1
                'http_code' => $response->getStatusCode(),
227 1
                'body'      => (string) $response->getBody(),
228
            ];
229 1
        } catch (\GuzzleHttp\Exception\ClientException $e) {
230 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...
231
        } catch (\GuzzleHttp\Exception\ServerException $e) {
232
            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...
233
        }
234
    }
235
236
    /**
237
     * Authenticate and recharge prevend request.
238
     *
239
     * @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...
240
     * @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...
241
     * @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...
242
     * @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...
243
     * @param integer $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...
244
     * @param integer $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...
245
     * @param boolean $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...
246
     * @param boolean $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...
247
     *
248
     *
249
{
250
  "smartloadId": "27821234567",
251
  "clientReference": "abc123",
252
  "smsRecipientMsisdn": "27821234567",
253
  "deviceId": "27821234567",
254
  "productId": 62,
255
  "amount": 12,
256
  "pinless": true,
257
  "sendSms": true
258
}
259
260
     */
261
    public function prevend()
262
    {
263
        try {
264
            $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...
265
                sprintf(
266
                    '/webservice/smartload/products/%d',
267
                    $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...
268
                ),
269
                [
270
                    'headers' => [
271
                        '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...
272
                    ],
273
                    'json' => [
274
                        'smartloadId'        => '',
275
                        'clientReference'    => '',
276
                        'smsRecipientMsisdn' => '',
277
                        'deviceId'           => '',
278
                        'productId'          => '',
279
                        'amount'             => '',
280
                        'pinless'            => '',
281
                        'sendSms'            => '',
282
                    ],
283
                ]
284
            );
285
286
            return [
287
                'status'    => 'ok',
288
                'http_code' => $response->getStatusCode(),
289
                'body'      => (string) $response->getBody(),
290
            ];
291
        } catch (\GuzzleHttp\Exception\ClientException $e) {
292
            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...
293
        } catch (\GuzzleHttp\Exception\ServerException $e) {
294
            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...
295
        }
296
    }
297
298
    /**
299
     * Authenticate and retrieves a list of all available networks.
300
     *
301
     * @param integer $id
302
     *
303
     * @throws Exception
304
     *
305
     * @return array
306
     */
307 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...
308
    {
309
        try {
310 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...
311 2
                sprintf(
312 2
                    '/webservice/smartload/products/%d',
313 2
                    $id
314
                ),
315
                [
316
                    'headers' => [
317 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...
318
                    ],
319
                ]
320
            );
321
322
            return [
323 1
                'status'    => 'ok',
324 1
                'http_code' => $response->getStatusCode(),
325 1
                'body'      => (string) $response->getBody(),
326
            ];
327 1
        } catch (\GuzzleHttp\Exception\ClientException $e) {
328 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...
329
        } catch (\GuzzleHttp\Exception\ServerException $e) {
330
            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...
331
        }
332
    }
333
334
    /**
335
     * Authenticate and checks if the provided ID (MSISDN) is registered with Smartload.
336
     *
337
     * @param string $dealerMsisdn
338
     *
339
     * @throws Exception
340
     *
341
     * @return array
342
     */
343 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...
344
    {
345
        try {
346
            $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...
347
                sprintf(
348
                    '/webservice/smartload/registered/%s',
349
                    $dealerMsisdn
350
                ),
351
                [
352
                    'headers' => [
353
                        '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...
354
                    ],
355
                ]
356
            );
357
358
            return [
359
                'status'    => 'ok',
360
                'http_code' => $response->getStatusCode(),
361
                'body'      => (string) $response->getBody(),
362
            ];
363
        } catch (\GuzzleHttp\Exception\ClientException $e) {
364
            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...
365
        } catch (\GuzzleHttp\Exception\ServerException $e) {
366
            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...
367
        }
368
    }
369
}
370