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 | * Instantiates a new Blob object. |
||
55 | * |
||
56 | * @param stdClass $data Raw blob data. |
||
57 | */ |
||
58 | public function __construct( stdClass $data ) { |
||
61 | |||
62 | public function id() { |
||
65 | |||
66 | public function set_id($id) { |
||
69 | |||
70 | /** |
||
71 | * Returns the raw blob content. |
||
72 | * |
||
73 | * @return string |
||
74 | */ |
||
75 | public function content() { |
||
78 | |||
79 | /** |
||
80 | * Set's the blob's content. |
||
81 | * |
||
82 | * @param string $content Raw blob content. |
||
83 | * @param bool $base64 Whether the content is base64 encoded. |
||
84 | * |
||
85 | * @return $this |
||
86 | */ |
||
87 | public function set_content( $content, $base64 = false ) { |
||
96 | /** |
||
97 | * Returns the blob sha. |
||
98 | * |
||
99 | * @return string |
||
100 | */ |
||
101 | public function sha() { |
||
104 | |||
105 | /** |
||
106 | * Return's the blob path. |
||
107 | * |
||
108 | * @return string |
||
109 | */ |
||
110 | public function path() { |
||
113 | |||
114 | /** |
||
115 | * Whether the blob has frontmatter. |
||
116 | * |
||
117 | * @return bool |
||
118 | */ |
||
119 | public function has_frontmatter() { |
||
122 | |||
123 | /** |
||
124 | * The front matter of github post |
||
125 | * @return string |
||
126 | */ |
||
127 | public function front_matter() { |
||
130 | |||
131 | /** |
||
132 | * Returns the formatted/filtered blob content used for import. |
||
133 | * |
||
134 | * @return string |
||
135 | */ |
||
136 | public function content_import() { |
||
155 | |||
156 | /** |
||
157 | * Returns the blob meta. |
||
158 | * |
||
159 | * @return array |
||
160 | */ |
||
161 | public function meta() { |
||
180 | |||
181 | /** |
||
182 | * Formats the blob into an API call body. |
||
183 | * |
||
184 | * @return stdClass |
||
185 | */ |
||
186 | // public function to_body() { |
||
187 | // $data = new stdClass; |
||
188 | |||
189 | // $data->mode = '100644'; |
||
190 | // $data->type = 'blob'; |
||
191 | |||
192 | // $data->path = $this->path(); |
||
193 | |||
194 | // if ( $this->sha() ) { |
||
195 | // $data->sha = $this->sha(); |
||
196 | // } else { |
||
197 | // $data->content = $this->content(); |
||
198 | // } |
||
199 | |||
200 | // return $data; |
||
201 | // } |
||
202 | |||
203 | |||
204 | /** |
||
205 | * Formats the blob into an API call body. |
||
206 | * |
||
207 | * @return stdClass |
||
208 | */ |
||
209 | public function to_body() { |
||
221 | |||
222 | /** |
||
223 | * Interprets the blob's data into properties. |
||
224 | */ |
||
225 | protected function interpret_data( $data ) { |
||
234 | } |
||
235 |