Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Gateway name has slash or underscore? #127

Closed
jamieburchell opened this issue Feb 2, 2019 · 2 comments
Closed

Docs: Gateway name has slash or underscore? #127

jamieburchell opened this issue Feb 2, 2019 · 2 comments
Labels

Comments

@jamieburchell
Copy link
Contributor

In the docs, the gateway names are inconsistent e.g. "SagePay/Server" vs "SagePay_Server". Which should it be? Does it matter?

@marncz
Copy link

marncz commented Feb 21, 2019

It doesn't really matter but you should choose one and stick to it, this function from omnipay-common takes care of it:

    /**
     * Resolve a short gateway name to a full namespaced gateway class.
     *
     * Class names beginning with a namespace marker (\) are left intact.
     * Non-namespaced classes are expected to be in the \Omnipay namespace, e.g.:
     *
     *      \Custom\Gateway     => \Custom\Gateway
     *      \Custom_Gateway     => \Custom_Gateway
     *      Stripe              => \Omnipay\Stripe\Gateway
     *      PayPal\Express      => \Omnipay\PayPal\ExpressGateway
     *      PayPal_Express      => \Omnipay\PayPal\ExpressGateway
     *
     * @param  string  $shortName The short gateway name
     * @return string  The fully namespaced gateway class name
     */
  public static function getGatewayClassName($shortName)
    {
        if (0 === strpos($shortName, '\\')) {
            return $shortName;
        }

        // replace underscores with namespace marker, PSR-0 style
        $shortName = str_replace('_', '\\', $shortName);
        if (false === strpos($shortName, '\\')) {
            $shortName .= '\\';
        }

        return '\\Omnipay\\'.$shortName.'Gateway';
    }

And you are right, it should be changed in the documentation to keep it consistent.

@judgej
Copy link
Member

judgej commented Mar 28, 2019

I think this answers the question. Thank you :-)

@judgej judgej closed this as completed Mar 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants