Skip to content

Commit d403e69

Browse files
authored
Merge pull request #250 from Mouke/master
allowing Classname::class syntax for getGatewayClassName()
2 parents 5b16387 + 38b960e commit d403e69

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/Common/Helper.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,17 @@ public static function getGatewayShortName($className)
122122
* PayPal\Express => \Omnipay\PayPal\ExpressGateway
123123
* PayPal_Express => \Omnipay\PayPal\ExpressGateway
124124
*
125-
* @param string $shortName The short gateway name
125+
* @param string $shortName The short gateway name or the FQCN
126126
* @return string The fully namespaced gateway class name
127127
*/
128128
public static function getGatewayClassName($shortName)
129129
{
130130
if (0 === strpos($shortName, '\\')) {
131131
return $shortName;
132132
}
133+
if (0 === strpos($shortName, 'Omnipay\\')) {
134+
return $shortName;
135+
}
133136

134137
// replace underscores with namespace marker, PSR-0 style
135138
$shortName = str_replace('_', '\\', $shortName);

tests/Common/HelperTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,10 @@ public function testGetGatewayClassNameUnderscoreNamespace()
143143
$class = Helper::getGatewayClassName('PayPal_Express');
144144
$this->assertEquals('\\Omnipay\\PayPal\\ExpressGateway', $class);
145145
}
146+
147+
public function testGetGatewayClassNameFQCN()
148+
{
149+
$class = Helper::getGatewayClassName('Omnipay\Stripe\PaymentIntentsGateway');
150+
$this->assertEquals('Omnipay\Stripe\PaymentIntentsGateway', $class);
151+
}
146152
}

0 commit comments

Comments
 (0)