Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 8 |
|
0.00% |
0 / 6 |
CRAP | |
0.00% |
0 / 1 |
| Unconfigured_Subscription_Service | |
0.00% |
0 / 6 |
|
0.00% |
0 / 6 |
42 | |
0.00% |
0 / 1 |
| available | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| initialize | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| visitor_can_view_content | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| visitor_has_subscription_access | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| is_current_user_pending_subscriber | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| access_url | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * The environment does not have a subscription service available. |
| 4 | * This represents this scenario. |
| 5 | * |
| 6 | * @package Automattic\Jetpack\Extensions\Premium_Content |
| 7 | */ |
| 8 | |
| 9 | namespace Automattic\Jetpack\Extensions\Premium_Content\Subscription_Service; |
| 10 | |
| 11 | use function site_url; |
| 12 | |
| 13 | if ( ! defined( 'ABSPATH' ) ) { |
| 14 | exit( 0 ); |
| 15 | } |
| 16 | |
| 17 | // phpcs:disable |
| 18 | |
| 19 | /** |
| 20 | * Class Unconfigured_Subscription_Service |
| 21 | * |
| 22 | * @package Automattic\Jetpack\Extensions\Premium_Content\Subscription_Service |
| 23 | */ |
| 24 | class Unconfigured_Subscription_Service implements Subscription_Service { |
| 25 | |
| 26 | /** |
| 27 | * Is always available because it is the fallback. |
| 28 | * |
| 29 | * @inheritDoc |
| 30 | */ |
| 31 | public static function available() { |
| 32 | return true; |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Function: initialize() |
| 37 | * |
| 38 | * @inheritDoc |
| 39 | */ |
| 40 | public function initialize() { |
| 41 | // noop. |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * No subscription service available, no users can see this content. |
| 46 | * |
| 47 | * @param array $valid_plan_ids . |
| 48 | * @param string $access_level . |
| 49 | * @param int|null $post_id Unused; accepted for callers that pass a post id. |
| 50 | */ |
| 51 | public function visitor_can_view_content( $valid_plan_ids, $access_level, $post_id = null ) { |
| 52 | return false; |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * An unconfigured service cannot establish subscription entitlement. |
| 57 | * |
| 58 | * @since $$next-version$$ |
| 59 | * |
| 60 | * @param array $valid_plan_ids Required subscription plan IDs. |
| 61 | * @param string $access_level Required access level. |
| 62 | * @param int|null $post_id Post to check. |
| 63 | * @return bool Always false. |
| 64 | */ |
| 65 | public function visitor_has_subscription_access( $valid_plan_ids, $access_level, $post_id = null ) { |
| 66 | return false; |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * is the current user a pending subscriber for the current site? |
| 71 | * |
| 72 | * @return bool |
| 73 | */ |
| 74 | public function is_current_user_pending_subscriber(): bool |
| 75 | { |
| 76 | return false; |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * The current visitor would like to obtain access. Where do they go? |
| 81 | * |
| 82 | * @param string $mode . |
| 83 | */ |
| 84 | public function access_url( $mode = 'subscribe' ) { |
| 85 | return site_url(); |
| 86 | } |
| 87 | |
| 88 | } |
| 89 | // phpcs:enable |