You are here

public function PasswordCharacter::getSummary in Password Policy 8.3

Returns a human-readable summary of the constraint.

Return value

string Summary of the constraint behaviors or restriction.

Overrides PasswordConstraintInterface::getSummary

File

password_policy_characters/src/Plugin/PasswordConstraint/PasswordCharacter.php, line 151

Class

PasswordCharacter
Enforces a number of a type of character in passwords.

Namespace

Drupal\password_policy_characters\Plugin\PasswordConstraint

Code

public function getSummary() {
  $configuration = $this
    ->getConfiguration();
  $summary = "";
  switch ($configuration['character_type']) {
    case 'uppercase':
      $summary = $this
        ->formatPlural($configuration['character_count'], 'Password must contain 1 uppercase character', 'Password must contain @count uppercase characters', [
        '@count' => $configuration['character_count'],
      ]);
      break;
    case 'lowercase':
      $summary = $this
        ->formatPlural($configuration['character_count'], 'Password must contain 1 lowercase character', 'Password must contain @count lowercase characters', [
        '@count' => $configuration['character_count'],
      ]);
      break;
    case 'letter':
      $summary = $this
        ->formatPlural($configuration['character_count'], 'Password must contain 1 letter character', 'Password must contain @count letter characters', [
        '@count' => $configuration['character_count'],
      ]);
      break;
    case 'special':
      $summary = $this
        ->formatPlural($configuration['character_count'], 'Password must contain 1 special character', 'Password must contain @count special characters', [
        '@count' => $configuration['character_count'],
      ]);
      break;
    case 'numeric':
      $summary = $this
        ->formatPlural($configuration['character_count'], 'Password must contain 1 numeric character', 'Password must contain @count numeric characters', [
        '@count' => $configuration['character_count'],
      ]);
      break;
  }
  return $summary;
}