Code Duplication    Length = 30-30 lines in 3 locations

src/Client.php 3 locations

@@ 84-113 (lines=30) @@
81
     *
82
     * @return array
83
     */
84
    public function auth($username, $password)
85
    {
86
        try {
87
            $response = $this->post(
88
                '/webservice/auth',
89
                [
90
                    'headers' => [
91
                        'Authorization' => sprintf(
92
                            'Basic %s',
93
                            base64_encode(
94
                                sprintf(
95
                                    '%s:%s',
96
                                    $username,
97
                                    $password
98
                                )
99
                            )
100
                        ),
101
                    ],
102
                ]
103
            );
104
105
            return [
106
                'status'    => 'ok',
107
                'http_code' => $response->getStatusCode(),
108
                'body'      => (string) $response->getBody(),
109
            ];
110
        } catch (\GuzzleHttp\Exception\ServerException $e) {
111
            return $this->parseError($e);
112
        }
113
    }
114
115
    /**
116
     * Authenticate and invalidates all the user allocated tokens
@@ 160-189 (lines=30) @@
157
     *
158
     * @return array
159
     */
160
    public function authFlush($username, $password)
161
    {
162
        try {
163
            $response = $this->delete(
164
                '/webservice/auth/token',
165
                [
166
                    'headers' => [
167
                        'Authorization' => sprintf(
168
                            'Basic %s',
169
                            base64_encode(
170
                                sprintf(
171
                                    '%s:%s',
172
                                    $username,
173
                                    $password
174
                                )
175
                            )
176
                        ),
177
                    ],
178
                ]
179
            );
180
181
            return [
182
                'status'    => 'ok',
183
                'http_code' => $response->getStatusCode(),
184
                'body'      => (string) $response->getBody(),
185
            ];
186
        } catch (\GuzzleHttp\Exception\ServerException $e) {
187
            return $this->parseError($e);
188
        }
189
    }
190
191
    /**
192
     * Authenticate and gets the number of available session tokens
@@ 201-230 (lines=30) @@
198
     *
199
     * @return array
200
     */
201
    public function authToken($username, $password)
202
    {
203
        try {
204
            $response = $this->get(
205
                '/webservice/auth/token',
206
                [
207
                    'headers' => [
208
                        'Authorization' => sprintf(
209
                            'Basic %s',
210
                            base64_encode(
211
                                sprintf(
212
                                    '%s:%s',
213
                                    $username,
214
                                    $password
215
                                )
216
                            )
217
                        ),
218
                    ],
219
                ]
220
            );
221
222
            return [
223
                'status'    => 'ok',
224
                'http_code' => $response->getStatusCode(),
225
                'body'      => (string) $response->getBody(),
226
            ];
227
        } catch (\GuzzleHttp\Exception\ServerException $e) {
228
            return $this->parseError($e);
229
        }
230
    }
231
232
    /**
233
     * Test SmartCall is responding.