Completed
Push — update/phpcs-likes ( c38a56...586808 )
by
unknown
253:23 queued 243:22
created

Initial_State   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 37
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A get_data() 0 5 1
A render() 0 3 1
1
<?php
2
/**
3
 * The React initial state.
4
 *
5
 * @package automattic/jetpack-connection-ui
6
 */
7
8
namespace Automattic\Jetpack\ConnectionUI;
9
10
use Automattic\Jetpack\Connection\Manager;
11
use Automattic\Jetpack\Connection\REST_Connector;
12
13
/**
14
 * The React initial state.
15
 */
16
class Initial_State {
17
18
	/**
19
	 * The connection manager object.
20
	 *
21
	 * @var Manager
22
	 */
23
	private $manager;
24
25
	/**
26
	 * The constructor.
27
	 */
28
	public function __construct() {
29
		$this->manager = new Manager();
30
	}
31
32
	/**
33
	 * Get the initial state data.
34
	 *
35
	 * @return array
36
	 */
37
	private function get_data() {
38
		return array(
39
			'connectionStatus' => REST_Connector::connection_status( false ),
40
		);
41
	}
42
43
	/**
44
	 * Render the initial state into a JavaScript variable.
45
	 *
46
	 * @return string
47
	 */
48
	public function render() {
49
		return 'var CUI_INITIAL_STATE=JSON.parse(decodeURIComponent("' . rawurlencode( wp_json_encode( $this->get_data() ) ) . '"));';
50
	}
51
52
}
53