trait PasswordPolicy

This trait contains a collection of getter functions for retrieving values regarding your password policy.

Values come from config/password.php. Applications without that file fall back to the PW_* variables in .env. Env::load() converts "true" to a boolean and numbers to integers, so values are normalized here rather than compared to strings.

Methods

bool
isMaxLength()

Gets max length rule for password.

bool
isMinLength()

Gets minimum rule for password.

bool
lowerChar()

Gets lower case character rule for password.

int
maxLength()

Gets max length for password.

int
minLength()

Gets minimum length for password.

bool
numericChar()

Gets numeric character rule for password.

bool
specialChar()

Gets special character rule for password.

bool
upperChar()

Gets upper case character rule for password.

static bool
policyFlag(string $configKey, string $envKey)

Reads a boolean password setting.

static int
policyLength(string $configKey, string $envKey, int $default)

Reads a numeric password setting.

Details

at line 22
bool isMaxLength()

Gets max length rule for password.

Return Value

bool

True if the maximum length rule is enforced.

at line 31
bool isMinLength()

Gets minimum rule for password.

Return Value

bool

True if the minimum length rule is enforced.

at line 40
bool lowerChar()

Gets lower case character rule for password.

Return Value

bool

True if a lower case character is required.

at line 49
int maxLength()

Gets max length for password.

Return Value

int

The maximum password length.

at line 58
int minLength()

Gets minimum length for password.

Return Value

int

The minimum password length.

at line 67
bool numericChar()

Gets numeric character rule for password.

Return Value

bool

True if a numeric character is required.

at line 76
bool specialChar()

Gets special character rule for password.

Return Value

bool

True if a special character is required.

at line 85
bool upperChar()

Gets upper case character rule for password.

Return Value

bool

True if an upper case character is required.

at line 96
static private bool policyFlag(string $configKey, string $envKey)

Reads a boolean password setting.

Parameters

string $configKey

Key in config/password.php.

string $envKey

Fallback .env variable.

Return Value

bool

The setting. Accepts true, "true", 1, "1", "on" and "yes".

at line 109
static private int policyLength(string $configKey, string $envKey, int $default)

Reads a numeric password setting.

Parameters

string $configKey

Key in config/password.php.

string $envKey

Fallback .env variable.

int $default

Used when neither source holds a number.

Return Value

int

The setting.