@@ -258,32 +258,17 @@ export class Finance {
258
258
*/
259
259
creditCardNumber ( provider = '' ) : string {
260
260
let format : string ;
261
- let formats : string | string [ ] ;
262
261
const localeFormat = this . faker . definitions . finance . credit_card ;
263
262
if ( provider in localeFormat ) {
264
- formats = localeFormat [ provider ] ; // there could be multiple formats
265
- if ( typeof formats === 'string' ) {
266
- format = formats ;
267
- } else {
268
- format = this . faker . random . arrayElement ( formats ) ;
269
- }
263
+ format = this . faker . random . arrayElement ( localeFormat [ provider ] ) ;
270
264
} else if ( provider . match ( / # / ) ) {
271
265
// The user chose an optional scheme
272
266
format = provider ;
273
267
} else {
274
268
// Choose a random provider
275
- // TODO ST-DDT 2022-01-30: #375 This is impossible to access
276
- if ( typeof localeFormat === 'string' ) {
277
- format = localeFormat ;
278
- } else if ( typeof localeFormat === 'object' ) {
279
- // Credit cards are in a object structure
280
- formats = this . faker . random . objectElement ( localeFormat , 'value' ) ; // There could be multiple formats
281
- if ( typeof formats === 'string' ) {
282
- format = formats ;
283
- } else {
284
- format = this . faker . random . arrayElement ( formats ) ;
285
- }
286
- }
269
+ // Credit cards are in an object structure
270
+ const formats = this . faker . random . objectElement ( localeFormat , 'value' ) ; // There could be multiple formats
271
+ format = this . faker . random . arrayElement ( formats ) ;
287
272
}
288
273
format = format . replace ( / \/ / g, '' ) ;
289
274
return this . Helpers . replaceCreditCardSymbols ( format ) ;
0 commit comments