Files
izyim/app/Traits/DeterminesIfUserPasswordMatchesRequirements.php
T
2019-02-14 11:43:19 +08:00

28 lines
626 B
PHP

<?php
namespace App\Traits;
trait DeterminesIfUserPasswordMatchesRequirements {
/**
* @param string $password
*
* @return bool
*/
private function doesPasswordMeetRequirements(string $password): bool {
$matches = [];
preg_match('/^.*(?=.{3,})(?=.*[a-z])(?=.*[A-Z])(?=.*[\d]).*$/', $password, $matches);
return count($matches) > 0;
}
/**
* @param string $password
*
* @return bool
*/
private function checkPasswordAndThrowIfInvalid(string $password): bool {
return $this->doesPasswordMeetRequirements($password) === true;
}
}