Code Duplication    Length = 35-35 lines in 2 locations

projects/plugins/jetpack/_inc/lib/class.jetpack-password-checker.php 1 location

@@ 463-497 (lines=35) @@
460
	 * @param String $password the password.
461
	 * @return Integer number of different character sets in use.
462
	 */
463
	protected function get_charset_size( $password ) {
464
		$size = 0;
465
466
		// Lowercase a-z.
467
		if ( preg_match( '/[a-z]/', $password ) ) {
468
			$size += 26;
469
		}
470
471
		// Uppercase A-Z.
472
		if ( preg_match( '/[A-Z]/', substr( $password, 1, -1 ) ) ) {
473
			$size += 26;
474
		}
475
476
		// Digits.
477
		if ( preg_match( '/\d/', substr( $password, 1, -1 ) ) ) {
478
			$size += 10;
479
		}
480
481
		// Over digits symbols.
482
		if ( preg_match( '/[!|@|#|$|%|^|&|*|(|)]/', $password ) ) {
483
			$size += 10;
484
		}
485
486
		// Other symbols.
487
		if ( preg_match( '#[`|~|-|_|=|+|\[|{|\]|}|\\|\|;:\'",<\.>/\?]#', $password ) ) {
488
			$size += 20;
489
		}
490
491
		// Spaces.
492
		if ( strpos( $password, ' ' ) ) {
493
			$size++;
494
		}
495
496
		return $size;
497
	}
498
499
	/**
500
	 * Shorthand for getting a character index.

projects/packages/password-checker/src/class-password-checker.php 1 location

@@ 488-522 (lines=35) @@
485
	 *
486
	 * @return int number of different character sets in use.
487
	 */
488
	protected function get_charset_size( $password ) {
489
		$size = 0;
490
491
		// Lowercase a-z.
492
		if ( preg_match( '/[a-z]/', $password ) ) {
493
			$size += 26;
494
		}
495
496
		// Uppercase A-Z.
497
		if ( preg_match( '/[A-Z]/', substr( $password, 1, - 1 ) ) ) {
498
			$size += 26;
499
		}
500
501
		// Digits.
502
		if ( preg_match( '/\d/', substr( $password, 1, - 1 ) ) ) {
503
			$size += 10;
504
		}
505
506
		// Over digits symbols.
507
		if ( preg_match( '/[!|@|#|$|%|^|&|*|(|)]/', $password ) ) {
508
			$size += 10;
509
		}
510
511
		// Other symbols.
512
		if ( preg_match( '#[`|~|-|_|=|+|\[|{|\]|}|\\|\|;:\'",<\.>/\?]#', $password ) ) {
513
			$size += 20;
514
		}
515
516
		// Spaces.
517
		if ( strpos( $password, ' ' ) ) {
518
			$size ++;
519
		}
520
521
		return $size;
522
	}
523
524
	/**
525
	 * Shorthand for getting a character index.