1 | <?php |
||
10 | class WordPress_GitHub_Sync_Payload { |
||
11 | |||
12 | /** |
||
13 | * Application container. |
||
14 | * |
||
15 | * @var WordPress_GitHub_Sync |
||
16 | */ |
||
17 | protected $app; |
||
18 | |||
19 | /** |
||
20 | * Payload data. |
||
21 | * |
||
22 | * @var stdClass |
||
23 | */ |
||
24 | protected $data; |
||
25 | |||
26 | /** |
||
27 | * Payload error. |
||
28 | * |
||
29 | * @var null|string |
||
30 | */ |
||
31 | protected $error = null; |
||
32 | |||
33 | /** |
||
34 | * WordPress_GitHub_Sync_Payload constructor. |
||
35 | * |
||
36 | * @param WordPress_GitHub_Sync $app Application container. |
||
37 | * @param string $raw_data Raw request data. |
||
38 | */ |
||
39 | 6 | public function __construct( WordPress_GitHub_Sync $app, $raw_data ) { |
|
66 | |||
67 | |||
68 | /** |
||
69 | * Attempts to get the JSON decoded string. |
||
70 | * |
||
71 | * @param string $raw_data A raw string from php://input |
||
72 | 4 | * |
|
73 | * @see WordPress_GitHub_Sync_Request::read_raw_data() |
||
74 | 4 | * |
|
75 | 1 | * @return Object|null An object from JSON Decode or false if failure. |
|
76 | * |
||
77 | * @author JayWood <[email protected]> |
||
78 | */ |
||
79 | 3 | private function get_payload_from_raw_response( $raw_data ) { |
|
102 | 1 | ||
103 | /** |
||
104 | * Returns whether payload should be imported. |
||
105 | * |
||
106 | 1 | * @return bool |
|
107 | */ |
||
108 | public function should_import() { |
||
144 | |||
145 | /** |
||
146 | * Returns the sha of the head commit. |
||
147 | * |
||
148 | * @return string |
||
149 | */ |
||
150 | 1 | public function get_commit_id() { |
|
153 | |||
154 | /** |
||
155 | * Returns the email address for the commit author. |
||
156 | * |
||
157 | * @return string |
||
158 | */ |
||
159 | 1 | public function get_author_email() { |
|
162 | |||
163 | /** |
||
164 | * Returns array commits for the payload. |
||
165 | * |
||
166 | * @return array |
||
167 | */ |
||
168 | 2 | public function get_commits() { |
|
171 | |||
172 | /** |
||
173 | * Returns the repository's full name. |
||
174 | * |
||
175 | * @return string |
||
176 | */ |
||
177 | public function get_repository_name() { |
||
180 | |||
181 | /** |
||
182 | * Return whether the payload has an error. |
||
183 | * |
||
184 | * @return bool |
||
185 | */ |
||
186 | public function has_error() { |
||
189 | |||
190 | /** |
||
191 | * Return the payload error string. |
||
192 | * |
||
193 | * @return string|null |
||
194 | */ |
||
195 | public function get_error() { |
||
198 | |||
199 | /** |
||
200 | * Returns the payload's commit message. |
||
201 | * |
||
202 | * @return string |
||
203 | */ |
||
204 | protected function message() { |
||
207 | } |
||
208 |