Refactor helper drift in lib: centralize theme/translation and remove app() hotspots
This commit is contained in:
@@ -2,8 +2,12 @@
|
||||
|
||||
namespace MintyPHP\Service\User;
|
||||
|
||||
use MintyPHP\Service\I18n\TranslatesServiceText;
|
||||
|
||||
class UserPasswordPolicyService
|
||||
{
|
||||
use TranslatesServiceText;
|
||||
|
||||
private const PASSWORD_MIN_LENGTH = 12;
|
||||
|
||||
public function validate(string $password, string $password2, bool $required, ?string $email): array
|
||||
@@ -61,15 +65,4 @@ class UserPasswordPolicyService
|
||||
return self::PASSWORD_MIN_LENGTH;
|
||||
}
|
||||
|
||||
// Wrapper so this service can be used in tests before the t() helper is loaded.
|
||||
private function translate(string $text, mixed ...$args): string
|
||||
{
|
||||
if (function_exists('t')) {
|
||||
return t($text, ...$args);
|
||||
}
|
||||
if ($args === []) {
|
||||
return $text;
|
||||
}
|
||||
return vsprintf($text, array_map(static fn ($arg) => (string) $arg, $args));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user