wp-pay-extensions /
memberpress
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * MemberPress |
||
| 4 | * |
||
| 5 | * @author Pronamic <[email protected]> |
||
| 6 | * @copyright 2005-2022 Pronamic |
||
| 7 | * @license GPL-3.0-or-later |
||
| 8 | * @package Pronamic\WordPress\Pay\Extensions\MemberPress |
||
| 9 | */ |
||
| 10 | |||
| 11 | namespace Pronamic\WordPress\Pay\Extensions\MemberPress; |
||
| 12 | |||
| 13 | use MeprSubscription; |
||
| 14 | use MeprTransaction; |
||
|
0 ignored issues
–
show
|
|||
| 15 | use MeprOptions; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * WordPress pay MemberPress |
||
| 19 | * |
||
| 20 | * @author Remco Tolsma |
||
| 21 | * @version 3.1.0 |
||
| 22 | * @since 1.0.0 |
||
| 23 | */ |
||
| 24 | class MemberPress { |
||
| 25 | /** |
||
| 26 | * MemberPress has no unambiguous way to request a transaction via an ID, |
||
| 27 | * so we have implemented a method for this. |
||
| 28 | * |
||
| 29 | * @link https://github.com/wp-premium/memberpress/blob/1.9.21/app/gateways/MeprStripeGateway.php#L928-L933 |
||
| 30 | * @link https://github.com/wp-premium/memberpress/blob/1.9.21/app/models/MeprTransaction.php#L156-L161 |
||
| 31 | * @param int|string|null $id ID. |
||
| 32 | * @return MeprTransaction|null |
||
| 33 | */ |
||
| 34 | public static function get_transaction_by_id( $id ) { |
||
| 35 | $object = MeprTransaction::get_one( $id ); |
||
| 36 | |||
| 37 | if ( ! \is_object( $object ) ) { |
||
| 38 | return null; |
||
| 39 | } |
||
| 40 | |||
| 41 | if ( ! isset( $object->id ) ) { |
||
| 42 | return null; |
||
| 43 | } |
||
| 44 | |||
| 45 | $transaction = new MeprTransaction(); |
||
| 46 | |||
| 47 | $transaction->load_data( $object ); |
||
| 48 | |||
| 49 | return $transaction; |
||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Get MemberPress subscription by ID. |
||
| 54 | * |
||
| 55 | * @link https://github.com/wp-premium/memberpress/blob/1.9.21/app/gateways/MeprStripeGateway.php#L1468 |
||
| 56 | * @link https://github.com/wp-premium/memberpress/blob/1.9.21/app/models/MeprSubscription.php#L211-L241 |
||
| 57 | * @param int|string|null $id ID. |
||
| 58 | * @return MeprSubscription|null |
||
| 59 | */ |
||
| 60 | public static function get_subscription_by_id( $id ) { |
||
| 61 | $object = MeprSubscription::get_one( $id ); |
||
| 62 | |||
| 63 | if ( ! \is_object( $object ) ) { |
||
| 64 | return null; |
||
| 65 | } |
||
| 66 | |||
| 67 | if ( ! isset( $object->id ) ) { |
||
| 68 | return null; |
||
| 69 | } |
||
| 70 | |||
| 71 | $subscription = new MeprSubscription(); |
||
| 72 | |||
| 73 | $subscription->load_data( $object ); |
||
| 74 | |||
| 75 | return $subscription; |
||
| 76 | } |
||
| 77 | |||
| 78 | /** |
||
| 79 | * Transaction has status. |
||
| 80 | * |
||
| 81 | * @param MeprTransaction $transaction MemberPress transaction object. |
||
| 82 | * @param string|string[] $status MemberPress transaction status string. |
||
| 83 | * @return bool Returns true if the transaction has the specified status, false otherwise. |
||
| 84 | */ |
||
| 85 | public static function transaction_has_status( MeprTransaction $transaction, $status ) { |
||
| 86 | if ( is_array( $status ) ) { |
||
| 87 | return in_array( $transaction->status, $status, true ); |
||
| 88 | } |
||
| 89 | |||
| 90 | return ( $transaction->status === $status ); |
||
| 91 | } |
||
| 92 | |||
| 93 | /** |
||
| 94 | * Get currency. |
||
| 95 | * |
||
| 96 | * @return string |
||
| 97 | */ |
||
| 98 | public static function get_currency() { |
||
| 99 | $mepr_options = MeprOptions::fetch(); |
||
| 100 | |||
| 101 | // @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/models/MeprOptions.php#L136-137 |
||
| 102 | return $mepr_options->currency_code; |
||
| 103 | } |
||
| 104 | } |
||
| 105 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths