Skip to content

Commit

Permalink
feat(authenticators): improve constructor parameter formatting
Browse files Browse the repository at this point in the history
- Improve formatting of constructor parameters for various authenticators
- Ensure consistency in parameter alignment and spacing
  • Loading branch information
guanguans committed Jul 8, 2024
1 parent 4d0c8c6 commit c6671e7
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 12 deletions.
8 changes: 6 additions & 2 deletions src/Foundation/Authenticators/BasicAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@
*/
class BasicAuthenticator extends OptionsAuthenticator
{
public function __construct(string $username, string $password, string $type = 'basic')
{
public function __construct(
string $username,
#[\SensitiveParameter]
string $password,
string $type = 'basic'
) {
parent::__construct([RequestOptions::AUTH => [$username, $password, $type]]);
}
}
7 changes: 5 additions & 2 deletions src/Foundation/Authenticators/BearerAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@

class BearerAuthenticator extends OptionsAuthenticator
{
public function __construct(string $token, ?string $bearer = 'Bearer')
{
public function __construct(
#[\SensitiveParameter]
string $token,
?string $bearer = 'Bearer'
) {
parent::__construct([RequestOptions::HEADERS => ['Authorization' => ltrim("$bearer $token")]]);
}
}
7 changes: 5 additions & 2 deletions src/Foundation/Authenticators/CertificateAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@

class CertificateAuthenticator extends OptionsAuthenticator
{
public function __construct(string $path, ?string $password = null)
{
public function __construct(
string $path,
#[\SensitiveParameter]
?string $password = null
) {
parent::__construct([RequestOptions::CERT => \is_string($password) ? [$path, $password] : $path]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@

class TokenUriTemplateAuthenticator extends UriTemplateAuthenticator
{
public function __construct(string $token)
{
public function __construct(
#[\SensitiveParameter]
string $token
) {
parent::__construct(['token' => $token]);
}
}
7 changes: 5 additions & 2 deletions src/Foundation/Authenticators/WebHookAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ class WebHookAuthenticator extends NullAuthenticator
private string $webHook;
private UriFactoryInterface $uriFactory;

public function __construct(string $webHook, ?UriFactoryInterface $uriFactory = null)
{
public function __construct(
#[\SensitiveParameter]
string $webHook,
?UriFactoryInterface $uriFactory = null
) {
$this->webHook = $webHook;
$this->uriFactory = $uriFactory ?? new HttpFactory;
}
Expand Down
7 changes: 5 additions & 2 deletions src/Foundation/Authenticators/WsseAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ class WsseAuthenticator extends NullAuthenticator
private string $username;
private string $password;

public function __construct(string $username, string $password)
{
public function __construct(
string $username,
#[\SensitiveParameter]
string $password
) {
$this->username = $username;
$this->password = $password;
}
Expand Down

0 comments on commit c6671e7

Please sign in to comment.