Code Duplication    Length = 27-27 lines in 2 locations

src/ExternalSign.php 2 locations

@@ 183-209 (lines=27) @@
180
     * @param  array  $body
181
     * @return object
182
     */
183
    public function createAppUrl(array $body)
184
    {
185
        // keys that are mandatory for this request
186
        $needKeys = ['DocumentId', 'SigneeRefId', 'UserAgent'];
187
188
        // if the body doesn't have needed fields, throw an exception
189
        if (array_intersect(array_keys($body), $needKeys) !== $needKeys) {
190
            throw new BadMethodCallException(
191
                'Missing fields in input array. Need '.implode(', ', $needKeys)
192
            );
193
        }
194
195
        // make the URL for this request
196
        $url = sprintf('%s/BankIDAppUrl', self::URI);
197
198
        // get the headers for this request
199
        $headers = $this->headers->make('PUT', $url, $body, true);
200
201
        // get the response
202
        $response = $this->client->put($url, [
203
            'headers' => $headers,
204
            'json' => $body,
205
        ]);
206
207
        // return the response
208
        return $response;
209
    }
210
211
    /**
212
     * Starts a BankID mobile sign session for the given document
@@ 218-244 (lines=27) @@
215
     * @param  array  $body
216
     * @return object
217
     */
218
    public function startMobile(array $body)
219
    {
220
        // keys that are mandatory for this request
221
        $needKeys = ['DateOfBirth', 'DocumentId', 'Mobile', 'SigneeRefId'];
222
223
        // if the body doesn't have needed fields, throw an exception
224
        if (array_intersect(array_keys($body), $needKeys) !== $needKeys) {
225
            throw new BadMethodCallException(
226
                'Missing fields in input array. Need '.implode(', ', $needKeys)
227
            );
228
        }
229
230
        // make the URL for this request
231
        $url = sprintf('%s/BankIDMobileSign', self::URI);
232
233
        // get the headers for this request
234
        $headers = $this->headers->make('PUT', $url, $body, true);
235
236
        // get the response
237
        $response = $this->client->put($url, [
238
            'headers' => $headers,
239
            'json' => $body,
240
        ]);
241
242
        // return the response
243
        return $response;
244
    }
245
}
246