-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
342 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Stadly\PasswordPolice\Rule; | ||
|
||
use Stadly\PasswordPolice\Policy; | ||
|
||
final class Symbol extends CharacterClass | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getMessage(): string | ||
{ | ||
$translator = Policy::getTranslator(); | ||
|
||
if ($this->max === null) { | ||
return $translator->trans( | ||
'There must be at least one symbol (%characters%).|'. | ||
'There must be at least %count% symbols (%characters%).', | ||
[ | ||
'%count%' => $this->min, | ||
'%characters%' => $this->characters, | ||
] | ||
); | ||
} | ||
|
||
if ($this->max === 0) { | ||
return $translator->trans( | ||
'There must be no symbols (%characters%).', | ||
['%characters%' => $this->characters] | ||
); | ||
} | ||
|
||
if ($this->min === 0) { | ||
return $translator->trans( | ||
'There must be at most one symbol (%characters%).|'. | ||
'There must be at most %count% symbols (%characters%).', | ||
[ | ||
'%count%' => $this->max, | ||
'%characters%' => $this->characters, | ||
] | ||
); | ||
} | ||
|
||
if ($this->min === $this->max) { | ||
return $translator->trans( | ||
'There must be exactly one symbol (%characters%).|'. | ||
'There must be exactly %count% symbols (%characters%).', | ||
[ | ||
'%count%' => $this->min, | ||
'%characters%' => $this->characters, | ||
] | ||
); | ||
} | ||
|
||
return $translator->trans( | ||
'There must be between %min% and %max% symbols (%characters%).', | ||
[ | ||
'%min%' => $this->min, | ||
'%max%' => $this->max, | ||
'%characters%' => $this->characters, | ||
] | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.