Failed Conditions
Push — develop ( bf2dba...b230b9 )
by Remco
04:46
created

MemberPress::get_currency()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 5
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * MemberPress
4
 *
5
 * @author    Pronamic <[email protected]>
6
 * @copyright 2005-2019 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 MeprTransaction;
14
use MeprOptions;
15
16
/**
17
 * WordPress pay MemberPress
18
 *
19
 * @author  Remco Tolsma
20
 * @version 2.0.1
21
 * @since   1.0.0
22
 */
23
class MemberPress {
24
	/**
25
	 * Transaction has status.
26
	 *
27
	 * @param MeprTransaction $transaction MemberPress transaction object.
28
	 * @param string|array    $status      MemberPress transaction status string.
29
	 *
30
	 * @return bool Returns true if the transaction has the specified status, false otherwise.
31
	 */
32
	public static function transaction_has_status( MeprTransaction $transaction, $status ) {
33
		if ( is_array( $status ) ) {
34
			return in_array( $transaction->status, $status, true );
35
		}
36
37
		return ( $transaction->status === $status );
38
	}
39
40
	/**
41
	 * Get currency.
42
	 *
43
	 * @return string
44
	 */
45
	public static function get_currency() {
46
		$mepr_options = MeprOptions::fetch();
47
48
		// @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/models/MeprOptions.php#L136-137
49
		return $mepr_options->currency_code;
50
	}
51
}
52