Skip to content

Commit

Permalink
refactor authentication classes
Browse files Browse the repository at this point in the history
  • Loading branch information
tomirons committed Mar 6, 2024
1 parent cdddd6f commit 881de62
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
10 changes: 9 additions & 1 deletion src/Authentication/AuthenticationMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,13 @@

abstract class AuthenticationMethod implements Arrayable
{
//
public function toArray(): array
{
return [
'key' => 'Authorization',
'value' => sprintf('%s {{token}}', $this->prefix()),
];
}

abstract public function prefix(): string;
}
4 changes: 2 additions & 2 deletions src/Authentication/Basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

class Basic extends AuthenticationMethod
{
public function toArray(): array
public function prefix(): string
{
return [];
return 'Basic';
}
}
4 changes: 2 additions & 2 deletions src/Authentication/Bearer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

class Bearer extends AuthenticationMethod
{
public function toArray(): array
public function prefix(): string
{
return [];
return 'Bearer';
}
}

0 comments on commit 881de62

Please sign in to comment.