Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
30.00% covered (danger)
30.00%
3 / 10
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
SAL_Platform
75.00% covered (warning)
75.00%
3 / 4
0.00% covered (danger)
0.00%
0 / 1
2.06
0.00% covered (danger)
0.00%
0 / 1
 __construct
75.00% covered (warning)
75.00%
3 / 4
0.00% covered (danger)
0.00%
0 / 1
2.06
 get_site
n/a
0 / 0
n/a
0 / 0
0
1<?php  // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
2/**
3 * SAL_Platform class which defines a token to later be associated with a Jetpack site
4 *
5 * @package automattic/jetpack
6 */
7
8if ( ! defined( 'ABSPATH' ) ) {
9    exit( 0 );
10}
11
12require_once __DIR__ . '/class.json-api-token.php';
13
14/**
15 * Base class for SAL_Platform
16 */
17abstract class SAL_Platform {
18    /**
19     * A token that will represent a SAL_Token instance, default is empty.
20     *
21     * @var SAL_Token
22     */
23    public $token;
24
25    /**
26     * Contructs the SAL_Platform instance
27     *
28     * @param SAL_Token $token The variable which will store the SAL_Token instance.
29     */
30    public function __construct( $token ) {
31        if ( is_array( $token ) ) {
32            $token = SAL_Token::from_rest_token( $token );
33        } else {
34            $token = SAL_Token::for_anonymous_user();
35        }
36
37        $this->token = $token;
38    }
39
40    /**
41     * This is the get_site function declaration, initially not implemented.
42     *
43     * @param int $blog_id The sites Jetpack blog ID.
44     * @see class.json-api-platform-jetpack.php for the implementation of this function.
45     */
46    abstract public function get_site( $blog_id );
47}
48
49if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
50    require_once dirname( WP_CONTENT_DIR ) . '/public.api/rest/sal/class.json-api-platform-wpcom.php';
51} else {
52    require_once __DIR__ . '/class.json-api-platform-jetpack.php';
53}