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

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