Skip to content

Commit a059c52

Browse files
committed
refactor: update exception classes to use static return type for fluent interface
1 parent 63ed7e0 commit a059c52

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

app/Exceptions/BizException.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ class BizException extends Exception
1717

1818
protected array $transParams = [];
1919

20-
public static function make(string $message): self
20+
public static function make(string $message): static
2121
{
2222
return new static($message);
2323
}
2424

25-
public function code(int $code): self
25+
public function code(int $code): static
2626
{
2727
$this->code = $code;
2828

2929
return $this;
3030
}
3131

32-
public function with(array|string $key, $value = null): self
32+
public function with(array|string $key, $value = null): static
3333
{
3434
if (is_array($key)) {
3535
$this->transParams = [...$this->transParams, ...$key];
@@ -47,7 +47,7 @@ public function logMessage(string $message)
4747
return $this;
4848
}
4949

50-
public function logContext(array $context): self
50+
public function logContext(array $context): static
5151
{
5252
$this->logContext = $context;
5353

contexts/Authorization/Domain/UserIdentity/Exceptions/AuthenticationFailureException.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66

77
use App\Exceptions\BizException;
88

9-
class AuthenticationFailureException extends BizException
9+
final class AuthenticationFailureException extends BizException
1010
{
11-
public static function make(string $message = ''): self
11+
public static function make(string $message = ''): static
1212
{
1313
$message = $message ?: 'Invalid login credentials or account access restricted';
14-
return (new static($message))->code(401);
14+
15+
/** @var static */
16+
return (new self($message))->code(401);
1517
}
1618
}

0 commit comments

Comments
 (0)