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

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