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 ) { |
||
102 | /** |
||
103 | * Returns the blob sha. |
||
104 | * |
||
105 | * @return string |
||
106 | */ |
||
107 | public function sha() { |
||
110 | |||
111 | /** |
||
112 | * Return's the blob path. |
||
113 | * |
||
114 | * @return string |
||
115 | */ |
||
116 | public function path() { |
||
119 | |||
120 | /** |
||
121 | * Whether the blob has frontmatter. |
||
122 | * |
||
123 | * @return bool |
||
124 | */ |
||
125 | public function has_frontmatter() { |
||
128 | |||
129 | /** |
||
130 | * The front matter of github post |
||
131 | * @return string |
||
132 | */ |
||
133 | public function front_matter() { |
||
136 | |||
137 | /** |
||
138 | * Content without front matter |
||
139 | * @return string |
||
140 | */ |
||
141 | public function post_content() { |
||
147 | |||
148 | /** |
||
149 | * Returns the formatted/filtered blob content used for import. |
||
150 | * |
||
151 | * @return string |
||
152 | */ |
||
153 | public function content_import() { |
||
172 | |||
173 | /** |
||
174 | * Returns the blob meta. |
||
175 | * |
||
176 | * @return array |
||
177 | */ |
||
178 | public function meta() { |
||
197 | |||
198 | /** |
||
199 | * Formats the blob into an API call body. |
||
200 | * |
||
201 | * @return stdClass |
||
202 | */ |
||
203 | // public function to_body() { |
||
204 | // $data = new stdClass; |
||
205 | |||
206 | // $data->mode = '100644'; |
||
207 | // $data->type = 'blob'; |
||
208 | |||
209 | // $data->path = $this->path(); |
||
210 | |||
211 | // if ( $this->sha() ) { |
||
212 | // $data->sha = $this->sha(); |
||
213 | // } else { |
||
214 | // $data->content = $this->content(); |
||
215 | // } |
||
216 | |||
217 | // return $data; |
||
218 | // } |
||
219 | |||
220 | |||
221 | /** |
||
222 | * Formats the blob into an API call body. |
||
223 | * |
||
224 | * @return stdClass |
||
225 | */ |
||
226 | public function to_body() { |
||
238 | |||
239 | /** |
||
240 | * Interprets the blob's data into properties. |
||
241 | */ |
||
242 | protected function interpret_data( $data ) { |
||
251 | } |
||
252 |