Class Helper
Helper class
This class defines various static utility functions that are in use
throughout the Omnipay system.
Methods summary
public static
string
|
#
camelCase( string $str )
Convert a string to camelCase. Strings already in camelCase will not be harmed.
Convert a string to camelCase. Strings already in camelCase will not be harmed.
Parameters
Returns
string camelCased output string
|
protected static
string
|
#
convertToLowercase( string $str )
Convert strings with underscores to be all lowercase before camelCase is preformed.
Convert strings with underscores to be all lowercase before camelCase is preformed.
Parameters
Returns
string The output string
|
public static
boolean
|
#
validateLuhn( string $number )
Validate a card number according to the Luhn algorithm.
Validate a card number according to the Luhn algorithm.
Parameters
- $number
- The card number to validate
Returns
boolean True if the supplied card number is valid
|
public static
|
#
initialize( mixed $target, array $parameters )
Initialize an object with a given array of parameters
Initialize an object with a given array of parameters
Parameters are automatically converted to camelCase. Any parameters which do
not match a setter on the target object are ignored.
Parameters
- $target
- The object to set parameters on
- $parameters
- An array of parameters to set
|
public static
|
#
getGatewayShortName( $className )
Resolve a gateway class to a short name.
Resolve a gateway class to a short name.
The short name can be used with GatewayFactory as an alias of the gateway class,
to create new instances of a gateway.
|
public static
string
|
#
getGatewayClassName( string $shortName )
Resolve a short gateway name to a full namespaced gateway class.
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
Parameters
- $shortName
- The short gateway name
Returns
string The fully namespaced gateway class name
|
public static
float
|
#
toFloat( $value )
Convert an amount into a float.
The float datatype can then be converted into the string
format that the remote gateway requies.
Convert an amount into a float.
The float datatype can then be converted into the string
format that the remote gateway requies.
Returns
float The amount converted to a float.
Throws
Var
string|int|float $value The value to convert.
|