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

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