1 | <?php |
||
10 | class Writing_On_GitHub_Blob { |
||
11 | |||
12 | /** |
||
13 | * Complete blob content. |
||
14 | * |
||
15 | * @var string |
||
16 | */ |
||
17 | protected $content; |
||
18 | |||
19 | /** |
||
20 | * Blob sha. |
||
21 | * |
||
22 | * @var string |
||
23 | */ |
||
24 | protected $sha; |
||
25 | |||
26 | /** |
||
27 | * Blob path. |
||
28 | * |
||
29 | * @var string |
||
30 | */ |
||
31 | protected $path; |
||
32 | |||
33 | /** |
||
34 | * Post id. |
||
35 | * |
||
36 | * @var int |
||
37 | */ |
||
38 | protected $id; |
||
39 | |||
40 | /** |
||
41 | * Whether the blob has frontmatter. |
||
42 | * |
||
43 | * @var boolean |
||
44 | */ |
||
45 | protected $frontmatter = false; |
||
46 | |||
47 | /** |
||
48 | * The front matter of github post |
||
49 | * @var string |
||
50 | */ |
||
51 | protected $front_matter = ''; |
||
52 | |||
53 | /** |
||
54 | * Content without front matter |
||
55 | * @var string |
||
56 | */ |
||
57 | protected $post_content; |
||
58 | |||
59 | /** |
||
60 | * Instantiates a new Blob object. |
||
61 | * |
||
62 | * @param stdClass $data Raw blob data. |
||
63 | */ |
||
64 | public function __construct( stdClass $data ) { |
||
67 | |||
68 | public function id() { |
||
71 | |||
72 | public function set_id($id) { |
||
75 | |||
76 | /** |
||
77 | * Returns the raw blob content. |
||
78 | * |
||
79 | * @return string |
||
80 | */ |
||
81 | public function content() { |
||
84 | |||
85 | /** |
||
86 | * Set's the blob's content. |
||
87 | * |
||
88 | * @param string $content Raw blob content. |
||
89 | * @param bool $base64 Whether the content is base64 encoded. |
||
90 | * |
||
91 | * @return $this |
||
92 | */ |
||
93 | public function set_content( $content, $base64 = false ) { |
||
106 | /** |
||
107 | * Returns the blob sha. |
||
108 | * |
||
109 | * @return string |
||
110 | */ |
||
111 | public function sha() { |
||
114 | |||
115 | /** |
||
116 | * Return's the blob path. |
||
117 | * |
||
118 | * @return string |
||
119 | */ |
||
120 | public function path() { |
||
123 | |||
124 | /** |
||
125 | * Whether the blob has frontmatter. |
||
126 | * |
||
127 | * @return bool |
||
128 | */ |
||
129 | public function has_frontmatter() { |
||
132 | |||
133 | /** |
||
134 | * The front matter of github post |
||
135 | * @return string |
||
136 | */ |
||
137 | public function front_matter() { |
||
140 | |||
141 | /** |
||
142 | * Content without front matter |
||
143 | * @return string |
||
144 | */ |
||
145 | public function post_content() { |
||
151 | |||
152 | /** |
||
153 | * Returns the formatted/filtered blob content used for import. |
||
154 | * |
||
155 | * @return string |
||
156 | */ |
||
157 | public function content_import() { |
||
176 | |||
177 | /** |
||
178 | * Returns the blob meta. |
||
179 | * |
||
180 | * @return array |
||
181 | */ |
||
182 | public function meta() { |
||
201 | |||
202 | /** |
||
203 | * Formats the blob into an API call body. |
||
204 | * |
||
205 | * @return stdClass |
||
206 | */ |
||
207 | // public function to_body() { |
||
208 | // $data = new stdClass; |
||
209 | |||
210 | // $data->mode = '100644'; |
||
211 | // $data->type = 'blob'; |
||
212 | |||
213 | // $data->path = $this->path(); |
||
214 | |||
215 | // if ( $this->sha() ) { |
||
216 | // $data->sha = $this->sha(); |
||
217 | // } else { |
||
218 | // $data->content = $this->content(); |
||
219 | // } |
||
220 | |||
221 | // return $data; |
||
222 | // } |
||
223 | |||
224 | |||
225 | /** |
||
226 | * Formats the blob into an API call body. |
||
227 | * |
||
228 | * @return stdClass |
||
229 | */ |
||
230 | public function to_body() { |
||
242 | |||
243 | /** |
||
244 | * Interprets the blob's data into properties. |
||
245 | */ |
||
246 | protected function interpret_data( $data ) { |
||
255 | } |
||
256 |