Last active
September 8, 2015 10:25
-
-
Save arichazan/11b579c873e4a043c88d to your computer and use it in GitHub Desktop.
doesPaymentMatchOptions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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