Issues (54)

src/SubscriptionStatuses.php (1 issue)

Labels
Severity
1
<?php
2
/**
3
 * Subscription statuses
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;
0 ignored issues
show
The type MeprSubscription 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...
14
use Pronamic\WordPress\Pay\Subscriptions\SubscriptionStatus;
15
16
/**
17
 * Subscription statuses
18
 *
19
 * @author  Remco Tolsma
20
 * @version 3.1.0
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
	 * @return string|null
32
	 */
33 5
	public static function transform( $status ) {
34
		switch ( $status ) {
35 5
			case MeprSubscription::$pending_str:
36 1
				return SubscriptionStatus::OPEN;
37 4
			case MeprSubscription::$active_str:
38 1
				return SubscriptionStatus::ACTIVE;
39 3
			case MeprSubscription::$suspended_str:
40
				// @todo set to 'On hold'?
41 1
				return null;
42 2
			case MeprSubscription::$cancelled_str:
43 1
				return SubscriptionStatus::CANCELLED;
44
		}
45
46 1
		return null;
47
	}
48
}
49