Test Failed
Push — develop ( 35cbae...2f2c0b )
by Reüel
05:52
created

SubscriptionStatuses::transform()   A

Complexity

Conditions 5
Paths 5

Size

Total Lines 10
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 5
eloc 9
c 1
b 0
f 0
nc 5
nop 1
dl 0
loc 10
ccs 9
cts 9
cp 1
crap 5
rs 9.6111
1
<?php
2
/**
3
 * Subscription statuses
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 MeprSubscription;
14
use Pronamic\WordPress\Pay\Subscriptions\SubscriptionStatus;
0 ignored issues
show
Bug introduced by
The type Pronamic\WordPress\Pay\S...ions\SubscriptionStatus was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
16
/**
17
 * Subscription statuses
18
 *
19
 * @author  Remco Tolsma
20
 * @version 2.0.1
21
 * @since   2.0.1
22
 */
23
class SubscriptionStatuses {
24
	/**
25
	 * Transform a MemberPress subscription status to a WordPress Pay subscription status.
26
	 *
27
	 * @link https://github.com/wp-premium/memberpress-basic/blob/master/app/models/MeprSubscription.php#L5-L9
28
	 *
29
	 * @param string $status MemberPress subscription status value.
30
	 *
31 5
	 * @return string|null
32
	 */
33 5
	public static function transform( $status ) {
34 1
		switch ( $status ) {
35 4
			case MeprSubscription::$pending_str:
36 1
				return SubscriptionStatus::OPEN;
37 3
			case MeprSubscription::$active_str:
38 1
				return SubscriptionStatus::ACTIVE;
39 2
			case MeprSubscription::$suspended_str:
40 1
				return null;
41
			case MeprSubscription::$cancelled_str:
42 1
				return SubscriptionStatus::CANCELLED;
43
		}
44
	}
45
}
46