1 | <?php |
||
10 | class WordPress_GitHub_Sync_Tree { |
||
11 | |||
12 | /** |
||
13 | * Current tree if retrieved, otherwise, error |
||
14 | * |
||
15 | * @var stdClass |
||
16 | */ |
||
17 | protected $data; |
||
18 | |||
19 | /** |
||
20 | * Tree's sha. |
||
21 | * |
||
22 | * @var string |
||
23 | */ |
||
24 | protected $sha; |
||
25 | |||
26 | /** |
||
27 | * Tree's url. |
||
28 | * |
||
29 | * @var string |
||
30 | */ |
||
31 | protected $url; |
||
32 | |||
33 | /** |
||
34 | * Blobs keyed by path. |
||
35 | * |
||
36 | * @var WordPress_GitHub_Sync_Blob[] |
||
37 | */ |
||
38 | protected $paths = array(); |
||
39 | |||
40 | /** |
||
41 | * Blobs keyed by sha. |
||
42 | * |
||
43 | * @var WordPress_GitHub_Sync_Blob[] |
||
44 | */ |
||
45 | protected $shas = array(); |
||
46 | |||
47 | /** |
||
48 | * Whether the tree has changed. |
||
49 | * |
||
50 | * @var bool |
||
51 | */ |
||
52 | protected $changed = false; |
||
53 | |||
54 | /** |
||
55 | * Represents a commit tree. |
||
56 | * |
||
57 | * @param stdClass $data Raw tree data. |
||
58 | */ |
||
59 | 13 | public function __construct( stdClass $data ) { |
|
64 | |||
65 | /** |
||
66 | * Returns the tree's raw data. |
||
67 | * |
||
68 | * @return stdClass |
||
69 | */ |
||
70 | 1 | public function get_data() { |
|
73 | |||
74 | /** |
||
75 | * Return's the tree's sha. |
||
76 | * |
||
77 | * @return string |
||
78 | */ |
||
79 | 4 | public function sha() { |
|
82 | |||
83 | /** |
||
84 | * Updates the tree's sha. |
||
85 | * |
||
86 | * @param string $sha Tree sha. |
||
87 | * |
||
88 | * @return $this |
||
89 | */ |
||
90 | 1 | public function set_sha( $sha ) { |
|
95 | |||
96 | /** |
||
97 | * Returns the tree's url. |
||
98 | * |
||
99 | * @return string |
||
100 | */ |
||
101 | 2 | public function url() { |
|
104 | |||
105 | /** |
||
106 | * Returns the tree's blobs. |
||
107 | * |
||
108 | * @return WordPress_GitHub_Sync_Blob[] |
||
109 | */ |
||
110 | 12 | public function blobs() { |
|
113 | |||
114 | /** |
||
115 | * Sets the tree's blobs to the provided array of blobs. |
||
116 | * |
||
117 | * @param WordPress_GitHub_Sync_Blob[] $blobs Array of blobs to set to tree. |
||
118 | * |
||
119 | * @return $this |
||
120 | */ |
||
121 | 4 | public function set_blobs( array $blobs ) { |
|
131 | |||
132 | /** |
||
133 | * Adds the provided blob to the tree. |
||
134 | * |
||
135 | * @param WordPress_GitHub_Sync_Blob $blob Blob to add to tree. |
||
136 | * |
||
137 | * @return $this |
||
138 | */ |
||
139 | 8 | public function add_blob( WordPress_GitHub_Sync_Blob $blob ) { |
|
144 | |||
145 | /** |
||
146 | * Adds the provided post as a blob to the tree. |
||
147 | * |
||
148 | * @param WordPress_GitHub_Sync_Post $post Post to add to tree. |
||
149 | * |
||
150 | * @return $this |
||
151 | */ |
||
152 | 4 | public function add_post_to_tree( WordPress_GitHub_Sync_Post $post ) { |
|
169 | |||
170 | /** |
||
171 | * Removes the provided post's blob from the tree. |
||
172 | * |
||
173 | * @param WordPress_GitHub_Sync_Post $post Post to remove from tree. |
||
174 | * |
||
175 | * @return $this |
||
176 | */ |
||
177 | 2 | public function remove_post_from_tree( WordPress_GitHub_Sync_Post $post ) { |
|
193 | |||
194 | /** |
||
195 | * Retrieves a tree blob for a given path. |
||
196 | * |
||
197 | * @param string $path Path to retrieve blob by. |
||
198 | * |
||
199 | * @return false|WordPress_GitHub_Sync_Blob |
||
200 | */ |
||
201 | 3 | public function get_blob_by_path( $path ) { |
|
204 | |||
205 | /** |
||
206 | * Retrieves a tree blob for a given path. |
||
207 | * |
||
208 | * @param string $sha Sha to retrieve blob by. |
||
209 | * |
||
210 | * @return false|WordPress_GitHub_Sync_Blob |
||
211 | */ |
||
212 | 4 | public function get_blob_by_sha( $sha ) { |
|
215 | |||
216 | /** |
||
217 | * Returns whether the tree has changed. |
||
218 | * |
||
219 | * @return bool |
||
220 | */ |
||
221 | 6 | public function is_changed() { |
|
224 | |||
225 | /** |
||
226 | * Formats the tree for an API call body. |
||
227 | * |
||
228 | * @return array |
||
229 | */ |
||
230 | 6 | public function to_body() { |
|
239 | |||
240 | /** |
||
241 | * Interprets the Tree from the data. |
||
242 | */ |
||
243 | 13 | protected function interpret_data() { |
|
247 | |||
248 | /** |
||
249 | * Returns a blob for the provided post. |
||
250 | * |
||
251 | * @param WordPress_GitHub_Sync_Post $post Post to retrieve blob for. |
||
252 | * |
||
253 | * @return WordPress_GitHub_Sync_Blob |
||
254 | */ |
||
255 | 4 | protected function get_blob_for_post( WordPress_GitHub_Sync_Post $post ) { |
|
266 | } |
||
267 |