Skip to content

Instantly share code, notes, and snippets.

@brutuscat
Forked from arichazan/gist:11b579c873e4a043c88d
Last active September 8, 2015 10:25
Show Gist options
  • Save brutuscat/1ca90fffb6a03c69faa8 to your computer and use it in GitHub Desktop.
Save brutuscat/1ca90fffb6a03c69faa8 to your computer and use it in GitHub Desktop.
doesPaymentMatchOptions
/*
* tests whether payment matches options
*
* returns 'true' if matches, 'false' otherwise
*
* $opts is an array of options to filter the payments by
* possible values are
* 'withoutPrefix' => 'prefix' - only select payment without this prefix
* 'withPrefix' => 'prefix' - only select payment with this prefix
* if no options are provided, always returns 'true'
*
*/
public static function isPaymentMatch($payment, $opts = [])
{
$withoutPrefix = null;
$withPrefix = null;
extract($opts, EXTR_IF_EXISTS);
if ($withoutPrefix) {
return $payment->getPaymentType()->hasNotPrefix($withoutPrefix);
} else {
return $payment->getPaymentType()->hasPrefix($withPrefix ?: '');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment