88use Chr15k \AuthGenerator \Contracts \Generator ;
99use Chr15k \AuthGenerator \DataTransfer \BasicAuthData ;
1010use Chr15k \AuthGenerator \Generators \BasicAuth as BasicAuthGenerator ;
11+ use SensitiveParameter ;
1112
12- final readonly class BasicAuthBuilder implements Builder
13+ final class BasicAuthBuilder implements Builder
1314{
14- private BasicAuthData $ data ;
15-
16- public function __construct ()
17- {
18- $ this -> data = new BasicAuthData ;
15+ public function __construct (
16+ private string $ username = '' ,
17+ private string $ password = ''
18+ ) {
19+ //
1920 }
2021
2122 /**
2223 * Set the username for Basic Auth.
2324 */
2425 public function username (string $ username ): self
2526 {
26- $ this ->data -> username = $ username ;
27+ $ this ->username = $ username ;
2728
2829 return $ this ;
2930 }
3031
3132 /**
3233 * Set the password for Basic Auth.
3334 */
34- public function password (string $ password ): self
35+ public function password (#[SensitiveParameter] string $ password ): self
3536 {
36- $ this ->data -> password = $ password ;
37+ $ this ->password = $ password ;
3738
3839 return $ this ;
3940 }
@@ -43,7 +44,12 @@ public function password(string $password): self
4344 */
4445 public function build (): Generator
4546 {
46- return new BasicAuthGenerator ($ this ->data );
47+ $ data = new BasicAuthData (
48+ username: $ this ->username ,
49+ password: $ this ->password
50+ );
51+
52+ return new BasicAuthGenerator ($ data );
4753 }
4854
4955 /**
0 commit comments