Skip to content

Commit 70af0a0

Browse files
committed
Allow passing PasswordExposedChecker object into Rule constructor (fixes #2)
1 parent 6f4aff0 commit 70af0a0

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/PasswordExposed.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@
88

99
class PasswordExposed implements Rule
1010
{
11+
private $passwordExposedChecker;
12+
13+
public function __construct(PasswordExposedChecker $passwordExposedChecker = null)
14+
{
15+
if (!$passwordExposedChecker) {
16+
$passwordExposedChecker = new PasswordExposedChecker();
17+
}
18+
19+
$this->passwordExposedChecker = $passwordExposedChecker;
20+
}
21+
1122
/**
1223
* Determine if the validation rule passes.
1324
*
@@ -18,7 +29,7 @@ class PasswordExposed implements Rule
1829
*/
1930
public function passes($attribute, $value)
2031
{
21-
$passwordStatus = (new PasswordExposedChecker())->passwordExposed($value);
32+
$passwordStatus = $this->passwordExposedChecker->passwordExposed($value);
2233

2334
return $passwordStatus !== PasswordStatus::EXPOSED;
2435
}

0 commit comments

Comments
 (0)