1 | <?php |
||
10 | class WordPress_GitHub_Sync_Commit { |
||
11 | |||
12 | /** |
||
13 | * Raw commit data. |
||
14 | * |
||
15 | * @var stdClass |
||
16 | */ |
||
17 | protected $data; |
||
18 | |||
19 | /** |
||
20 | * Commit sha. |
||
21 | * |
||
22 | * @var string |
||
23 | */ |
||
24 | protected $sha; |
||
25 | |||
26 | /** |
||
27 | * Commit message. |
||
28 | * |
||
29 | * @var string |
||
30 | */ |
||
31 | protected $message = ''; |
||
32 | |||
33 | /** |
||
34 | * Commit tree. |
||
35 | * |
||
36 | * @var WordPress_GitHub_Sync_Tree |
||
37 | */ |
||
38 | protected $tree; |
||
39 | |||
40 | /** |
||
41 | * Commit api url. |
||
42 | * |
||
43 | * @var string |
||
44 | */ |
||
45 | protected $url; |
||
46 | |||
47 | /** |
||
48 | * Commit author. |
||
49 | * |
||
50 | * @var stdClass|false |
||
51 | */ |
||
52 | protected $author; |
||
53 | |||
54 | /** |
||
55 | * Commit committer. |
||
56 | * |
||
57 | * @var stdClass|false |
||
58 | */ |
||
59 | protected $committer; |
||
60 | |||
61 | /** |
||
62 | * Commit parents. |
||
63 | * |
||
64 | * @var string[] |
||
65 | */ |
||
66 | protected $parents; |
||
67 | |||
68 | /** |
||
69 | * Instantiates a new Commit object. |
||
70 | * |
||
71 | * @param stdClass $data Raw commit data. |
||
72 | */ |
||
73 | 13 | public function __construct( stdClass $data ) { |
|
78 | |||
79 | /** |
||
80 | * Returns the commit sha. |
||
81 | * |
||
82 | * @return string |
||
83 | */ |
||
84 | 3 | public function sha() { |
|
87 | |||
88 | /** |
||
89 | * Return the commit's API url. |
||
90 | * |
||
91 | * @return string |
||
92 | */ |
||
93 | 2 | public function url() { |
|
96 | |||
97 | /** |
||
98 | * Return the commit author. |
||
99 | * |
||
100 | * @return stdClass|false |
||
101 | */ |
||
102 | 3 | public function author() { |
|
105 | |||
106 | /** |
||
107 | * Return's the commit author's email. |
||
108 | * |
||
109 | * @return string |
||
110 | */ |
||
111 | 2 | public function author_email() { |
|
118 | |||
119 | /** |
||
120 | * Set's the commit author. |
||
121 | * |
||
122 | * @param stdClass $author Commit author data. |
||
123 | * |
||
124 | * @return $this |
||
125 | */ |
||
126 | 1 | public function set_author( stdClass $author ) { |
|
133 | |||
134 | /** |
||
135 | * Return the commit committer. |
||
136 | * |
||
137 | * @return stdClass|false |
||
138 | */ |
||
139 | 3 | public function committer() { |
|
142 | |||
143 | /** |
||
144 | * Set's the commit committer. |
||
145 | * |
||
146 | * @param stdClass $committer Committer data. |
||
147 | * |
||
148 | * @return $this |
||
149 | */ |
||
150 | 1 | public function set_committer( stdClass $committer ) { |
|
157 | |||
158 | /** |
||
159 | * Returns the commit message, if set. |
||
160 | * |
||
161 | * @return string |
||
162 | */ |
||
163 | 3 | public function message() { |
|
166 | |||
167 | /** |
||
168 | * Set's the commit message; |
||
169 | * |
||
170 | * @param string $message Commit message. |
||
171 | * |
||
172 | * @return $this |
||
173 | */ |
||
174 | 3 | public function set_message( $message ) { |
|
181 | |||
182 | /** |
||
183 | * Return the commit parents. |
||
184 | * |
||
185 | * @return string[] |
||
186 | */ |
||
187 | 6 | public function parents() { |
|
190 | |||
191 | /** |
||
192 | * Returns the commit's tree's sha. |
||
193 | * |
||
194 | * @return string |
||
195 | */ |
||
196 | 8 | public function tree_sha() { |
|
207 | |||
208 | /** |
||
209 | * Return's the commit's tree. |
||
210 | * |
||
211 | * @return WordPress_GitHub_Sync_Tree |
||
212 | */ |
||
213 | 5 | public function tree() { |
|
216 | |||
217 | /** |
||
218 | * Set the commit's tree. |
||
219 | * |
||
220 | * @param WordPress_GitHub_Sync_Tree $tree New tree for commit. |
||
221 | * |
||
222 | * @return $this |
||
223 | */ |
||
224 | 5 | public function set_tree( WordPress_GitHub_Sync_Tree $tree ) { |
|
229 | |||
230 | /** |
||
231 | * Returns whether the commit is currently synced. |
||
232 | * |
||
233 | * The commit message of every commit that's exported |
||
234 | * by WPGHS ends with '- wpghs', so we don't sync those |
||
235 | * commits down. |
||
236 | * |
||
237 | * @return bool |
||
238 | */ |
||
239 | 2 | public function already_synced() { |
|
242 | |||
243 | /** |
||
244 | * Transforms the commit into the API |
||
245 | * body required to create a new commit. |
||
246 | * |
||
247 | * @return array |
||
248 | */ |
||
249 | 1 | public function to_body() { |
|
259 | |||
260 | /** |
||
261 | * Interprets the raw data object into commit properties. |
||
262 | */ |
||
263 | 13 | protected function interpret_data() { |
|
271 | |||
272 | /** |
||
273 | * Assigns the current sha to be its parent. |
||
274 | */ |
||
275 | 5 | protected function set_to_parent() { |
|
281 | } |
||
282 |