diff --git a/src/EasySms.php b/src/EasySms.php index 7dcd4c9..9b4809e 100644 --- a/src/EasySms.php +++ b/src/EasySms.php @@ -261,6 +261,10 @@ protected function makeGateway($gateway, $config) */ protected function formatGatewayClassName($name) { + if (\class_exists($name) && \in_array(GatewayInterface::class, \class_implements($name))) { + return $name; + } + $name = \ucfirst(\str_replace(['-', '_', ''], '', $name)); return __NAMESPACE__."\\Gateways\\{$name}Gateway"; diff --git a/tests/EasySmsTest.php b/tests/EasySmsTest.php index d2c18fc..768de79 100644 --- a/tests/EasySmsTest.php +++ b/tests/EasySmsTest.php @@ -66,7 +66,7 @@ public function testGatewayWithDefaultSetting() $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage( sprintf( - 'Class "%s" is a invalid easy-sms gateway.', + 'Class "Overtrue\EasySms\Gateways\%sGateway" is a invalid easy-sms gateway.', DummyInvalidGatewayForTest::class ) );