Code Duplication    Length = 18-23 lines in 5 locations

src/Client.php 5 locations

@@ 68-85 (lines=18) @@
65
     *
66
     * @return array
67
     */
68
    public function getDealerBalance()
69
    {
70
        try {
71
            $response = $this->get('/SmartcallRestfulProxy/balance');
72
73
            return [
74
                'status'    => 'ok',
75
                'http_code' => $response->getStatusCode(),
76
                'body'      => (string) $response->getBody(),
77
            ];
78
        } catch (\GuzzleHttp\Exception\ServerException $e) {
79
            return [
80
                'status'    => 'error',
81
                'http_code' => $e->getResponse()->getStatusCode(),
82
                'body'      => (string) $e->getResponse()->getBody(),
83
            ];
84
        }
85
    }
86
87
    /**
88
     * Fetches the Dealer Balance from SmartCall.
@@ 94-116 (lines=23) @@
91
     *
92
     * @return array
93
     */
94
    public function isDealerRegistered($msisdn)
95
    {
96
        try {
97
            $response = $this->get(
98
                sprintf(
99
                    '/SmartcallRestfulProxy/registered/%s',
100
                    $msisdn
101
                )
102
            );
103
104
            return [
105
                'status'    => 'ok',
106
                'http_code' => $response->getStatusCode(),
107
                'body'      => (string) $response->getBody(),
108
            ];
109
        } catch (\GuzzleHttp\Exception\ServerException $e) {
110
            return [
111
                'status'    => 'error',
112
                'http_code' => $e->getResponse()->getStatusCode(),
113
                'body'      => (string) $e->getResponse()->getBody(),
114
            ];
115
        }
116
    }
117
118
    /**
119
     * Fetches the Product from SmartCall.
@@ 162-179 (lines=18) @@
159
     *
160
     * @return array
161
     */
162
    public function getProducts()
163
    {
164
        try {
165
            $response = $this->get('/SmartcallRestfulProxy/all_networks_js');
166
167
            return [
168
                'status'    => 'ok',
169
                'http_code' => $response->getStatusCode(),
170
                'body'      => (string) $response->getBody(),
171
            ];
172
        } catch (\GuzzleHttp\Exception\ServerException $e) {
173
            return [
174
                'status'    => 'error',
175
                'http_code' => $e->getResponse()->getStatusCode(),
176
                'body'      => (string) $e->getResponse()->getBody(),
177
            ];
178
        }
179
    }
180
181
    /**
182
     * Fetches the details of the last transaction processed from SmartCall.
@@ 188-205 (lines=18) @@
185
     *
186
     * @return array
187
     */
188
    public function getLastTransaction()
189
    {
190
        try {
191
            $response = $this->get('/SmartcallRestfulProxy/last_transaction_js');
192
193
            return [
194
                'status'    => 'ok',
195
                'http_code' => $response->getStatusCode(),
196
                'body'      => (string) $response->getBody(),
197
            ];
198
        } catch (\GuzzleHttp\Exception\ServerException $e) {
199
            return [
200
                'status'    => 'error',
201
                'http_code' => $e->getResponse()->getStatusCode(),
202
                'body'      => (string) $e->getResponse()->getBody(),
203
            ];
204
        }
205
    }
206
207
    /**
208
     * Fetches the Product List by the specified network identifier from SmartCall.
@@ 216-238 (lines=23) @@
213
     *
214
     * @return array
215
     */
216
    public function getProductsByNetwork($networkId)
217
    {
218
        try {
219
            $response = $this->get(
220
                sprintf(
221
                    '/SmartcallRestfulProxy/network_js/%d',
222
                    $networkId
223
                )
224
            );
225
226
            return [
227
                'status'    => 'ok',
228
                'http_code' => $response->getStatusCode(),
229
                'body'      => (string) $response->getBody(),
230
            ];
231
        } catch (\GuzzleHttp\Exception\ServerException $e) {
232
            return [
233
                'status'    => 'error',
234
                'http_code' => $e->getResponse()->getStatusCode(),
235
                'body'      => (string) $e->getResponse()->getBody(),
236
            ];
237
        }
238
    }
239
240
    /**
241
     * Purchase a voucher or do a pinless recharge on SmartCall.