-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDatapoint.php
More file actions
124 lines (109 loc) · 2.23 KB
/
Copy pathDatapoint.php
File metadata and controls
124 lines (109 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
/**
* Class Google\Site_Kit\Core\Modules\Datapoint
*
* @package Google\Site_Kit\Core\Modules
* @copyright 2022 Google LLC
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link https://sitekit.withgoogle.com
*/
namespace Google\Site_Kit\Core\Modules;
/**
* Class representing a datapoint definition.
*
* @since 1.77.0
* @access private
* @ignore
*/
class Datapoint {
/**
* Service identifier.
*
* @since 1.77.0
* @var string
*/
private $service = '';
/**
* Required scopes.
*
* @since 1.77.0
* @var string[]
*/
private $scopes = array();
/**
* Shareable status.
*
* @since 1.77.0
* @var bool
*/
private $shareable;
/**
* Request scopes message.
*
* @since 1.77.0
* @var string
*/
private $request_scopes_message;
/**
* Constructor.
*
* @since 1.77.0
*
* @param array $definition Definition fields.
*/
public function __construct( array $definition ) {
$this->shareable = ! empty( $definition['shareable'] );
if ( isset( $definition['service'] ) && is_string( $definition['service'] ) ) {
$this->service = $definition['service'];
}
if ( isset( $definition['scopes'] ) && is_array( $definition['scopes'] ) ) {
$this->scopes = $definition['scopes'];
}
if ( isset( $definition['request_scopes_message'] ) && is_string( $definition['request_scopes_message'] ) ) {
$this->request_scopes_message = $definition['request_scopes_message'];
}
}
/**
* Checks if the datapoint is shareable.
*
* @since 1.77.0
*
* @return bool
*/
public function is_shareable() {
return $this->shareable;
}
/**
* Gets the service identifier.
*
* @since 1.77.0
*
* @return string
*/
public function get_service() {
return $this->service;
}
/**
* Gets the list of required scopes.
*
* @since 1.77.0
*
* @return string[]
*/
public function get_required_scopes() {
return $this->scopes;
}
/**
* Gets the request scopes message.
*
* @since 1.77.0
*
* @return string
*/
public function get_request_scopes_message() {
if ( $this->request_scopes_message ) {
return $this->request_scopes_message;
}
return __( 'You’ll need to grant Site Kit permission to do this.', 'google-site-kit' );
}
}