Code Duplication    Length = 35-35 lines in 2 locations

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

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

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.