Skip to content

Commit ff49b5b

Browse files
Add Custom Exception
1 parent 0c4d175 commit ff49b5b

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace Mkdev\LaravelAdvancedOTP\Exceptions;
4+
use Exception;
5+
6+
class InvalidOTPMethodException extends Exception
7+
{
8+
public function __construct()
9+
{
10+
parent::__construct();
11+
}
12+
}

src/LaravelAdvancedOTP.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,19 @@
33
namespace Mkdev\LaravelAdvancedOTP;
44

55

6-
use http\Exception\BadConversionException;
76
use Mkdev\LaravelAdvancedOTP\Contracts\OTPProviderContract;
87
use Mkdev\LaravelAdvancedOTP\Enums\OTPStatusEnum;
8+
use Mkdev\LaravelAdvancedOTP\Exceptions\InvalidOTPMethodException;
99
use Mkdev\LaravelAdvancedOTP\Interfaces\OTPProviderInterface;
1010

1111
class LaravelAdvancedOTP
1212
{
1313

14-
1514
private function getMethod(string $method)
1615
{
1716
$otpMethod = new $method();
1817
if (!$otpMethod instanceof OTPProviderContract) {
19-
throw new BadConversionException;
18+
throw new InvalidOTPMethodException;
2019
}
2120
return $otpMethod;
2221
}

0 commit comments

Comments
 (0)