Completed
Push — add/product-ratings-to-search ( 91683c...b05261 )
by
unknown
344:08 queued 334:42
created

Jetpack_Token_Subscription_Service::available()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * A paywall that exchanges JWT tokens from WordPress.com to allow
4
 * a current visitor to view content that has been deemed "Premium content".
5
 *
6
 * @package Automattic\Jetpack\Extensions\Premium_Content
7
 */
8
9
namespace Automattic\Jetpack\Extensions\Premium_Content\Subscription_Service;
10
11
use Automattic\Jetpack\Connection\Manager;
12
13
/**
14
 * Class Jetpack_Token_Subscription_Service
15
 *
16
 * @package Automattic\Jetpack\Extensions\Premium_Content\Subscription_Service
17
 */
18
class Jetpack_Token_Subscription_Service extends Token_Subscription_Service {
19
20
	/**
21
	 * Is the Jetpack_Options class available?
22
	 *
23
	 * @return bool Whether Jetpack_Options class exists.
24
	 */
25
	public static function available() {
26
		return class_exists( '\Jetpack_Options' );
27
	}
28
29
	/**
30
	 * Get the site ID.
31
	 *
32
	 * @return int The site ID.
33
	 */
34
	public function get_site_id() {
35
		return \Jetpack_Options::get_option( 'id' );
36
	}
37
38
	/**
39
	 * Get the key.
40
	 *
41
	 * @return string The key.
42
	 */
43
	public function get_key() {
44
		$connection = new Manager();
45
		$token      = $connection->get_access_token();
46
		if ( ! isset( $token->secret ) ) {
47
			return false;
48
		}
49
		return $token->secret;
50
	}
51
}
52