Passed
Push — ci ( c003f9...38d7bc )
by litefeel
02:34
created
lib/client/base.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
 	 */
42 42
 	protected function call( $method, $endpoint, $body = array() ) {
43 43
 		if ( is_wp_error( $error = $this->can_call() ) ) {
44
-            /* @var WP_Error $error */
44
+			/* @var WP_Error $error */
45 45
 			return $error;
46 46
 		}
47 47
 
Please login to merge, or discard this patch.
Spacing   +25 added lines, -26 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	 *
27 27
 	 * @param Writing_On_GitHub $app Application container.
28 28
 	 */
29
-	public function __construct( Writing_On_GitHub $app ) {
29
+	public function __construct(Writing_On_GitHub $app) {
30 30
 		$this->app = $app;
31 31
 	}
32 32
 
@@ -39,8 +39,8 @@  discard block
 block discarded – undo
39 39
 	 *
40 40
 	 * @return stdClass|WP_Error
41 41
 	 */
42
-	protected function call( $method, $endpoint, $body = array() ) {
43
-		if ( is_wp_error( $error = $this->can_call() ) ) {
42
+	protected function call($method, $endpoint, $body = array()) {
43
+		if (is_wp_error($error = $this->can_call())) {
44 44
             /* @var WP_Error $error */
45 45
 			return $error;
46 46
 		}
@@ -52,24 +52,23 @@  discard block
 block discarded – undo
52 52
 			),
53 53
 		);
54 54
 
55
-		if ( 'GET' !== $method ) {
56
-			$args['body'] = function_exists( 'wp_json_encode' ) ?
57
-				wp_json_encode( $body ) :
58
-				json_encode( $body );
55
+		if ('GET' !== $method) {
56
+			$args['body'] = function_exists('wp_json_encode') ?
57
+				wp_json_encode($body) : json_encode($body);
59 58
 		}
60 59
 
61 60
 		$tmpbody = isset($args['body']) ? $args['body'] : '';
62 61
 		error_log("writing-on-github-call $method $endpoint $tmpbody");
63 62
 
64
-		$response = wp_remote_request( $endpoint, $args );
65
-		$status   = wp_remote_retrieve_header( $response, 'status' );
66
-		$body     = json_decode( wp_remote_retrieve_body( $response ) );
63
+		$response = wp_remote_request($endpoint, $args);
64
+		$status   = wp_remote_retrieve_header($response, 'status');
65
+		$body     = json_decode(wp_remote_retrieve_body($response));
67 66
 
68
-		if ( '2' !== substr( $status, 0, 1 ) && '3' !== substr( $status, 0, 1 ) ) {
67
+		if ('2' !== substr($status, 0, 1) && '3' !== substr($status, 0, 1)) {
69 68
 			return new WP_Error(
70
-				strtolower( str_replace( ' ', '_', $status ) ),
69
+				strtolower(str_replace(' ', '_', $status)),
71 70
 				sprintf(
72
-					__( 'Method %s to endpoint %s failed with error: %s', 'writing-on-github' ),
71
+					__('Method %s to endpoint %s failed with error: %s', 'writing-on-github'),
73 72
 					$method,
74 73
 					$endpoint,
75 74
 					$body && $body->message ? $body->message : 'Unknown error'
@@ -86,28 +85,28 @@  discard block
 block discarded – undo
86 85
 	 * @return true|WP_Error
87 86
 	 */
88 87
 	protected function can_call() {
89
-		if ( ! $this->oauth_token() ) {
88
+		if ( ! $this->oauth_token()) {
90 89
 			return new WP_Error(
91 90
 				'missing_token',
92
-				__( 'Writing On GitHub needs an auth token. Please update your settings.', 'writing-on-github' )
91
+				__('Writing On GitHub needs an auth token. Please update your settings.', 'writing-on-github')
93 92
 			);
94 93
 		}
95 94
 
96 95
 		$repo = $this->repository();
97 96
 
98
-		if ( ! $repo ) {
97
+		if ( ! $repo) {
99 98
 			return new WP_Error(
100 99
 				'missing_repository',
101
-				__( 'Writing On GitHub needs a repository. Please update your settings.', 'writing-on-github' )
100
+				__('Writing On GitHub needs a repository. Please update your settings.', 'writing-on-github')
102 101
 			);
103 102
 		}
104 103
 
105
-		$parts = explode( '/', $repo );
104
+		$parts = explode('/', $repo);
106 105
 
107
-		if ( 2 !== count( $parts ) ) {
106
+		if (2 !== count($parts)) {
108 107
 			return new WP_Error(
109 108
 				'malformed_repository',
110
-				__( 'Writing On GitHub needs a properly formed repository. Please update your settings.', 'writing-on-github' )
109
+				__('Writing On GitHub needs a properly formed repository. Please update your settings.', 'writing-on-github')
111 110
 			);
112 111
 		}
113 112
 
@@ -120,7 +119,7 @@  discard block
 block discarded – undo
120 119
 	 * @return string
121 120
 	 */
122 121
 	public function repository() {
123
-		return (string) get_option( self::REPO_OPTION_KEY );
122
+		return (string) get_option(self::REPO_OPTION_KEY);
124 123
 	}
125 124
 
126 125
 	/**
@@ -129,18 +128,18 @@  discard block
 block discarded – undo
129 128
 	 * @return string
130 129
 	 */
131 130
 	public function oauth_token() {
132
-		return (string) get_option( self::TOKEN_OPTION_KEY );
131
+		return (string) get_option(self::TOKEN_OPTION_KEY);
133 132
 	}
134 133
 
135 134
 	/**
136 135
 	 * Returns the GitHub host to sync with (for GitHub Enterprise support)
137 136
 	 */
138 137
 	public function api_base() {
139
-		return get_option( self::HOST_OPTION_KEY );
138
+		return get_option(self::HOST_OPTION_KEY);
140 139
 	}
141 140
 
142 141
 	public function branch() {
143
-		$branch = get_option( self::BRANCH_OPTION_KEY );
142
+		$branch = get_option(self::BRANCH_OPTION_KEY);
144 143
 		return $branch ? $branch : 'master';
145 144
 	}
146 145
 
@@ -201,11 +200,11 @@  discard block
 block discarded – undo
201 200
 	 *
202 201
 	 * Returns String the relative API call path
203 202
 	 */
204
-	public function content_endpoint( $path = false ) {
203
+	public function content_endpoint($path = false) {
205 204
 		$url = $this->api_base() . '/repos/';
206 205
 		$url = $url . $this->repository() . '/contents';
207 206
 
208
-		if ( ! empty($path) ) {
207
+		if ( ! empty($path)) {
209 208
 			$url .= '/' . $path;
210 209
 		}
211 210
 
Please login to merge, or discard this patch.
lib/import.php 2 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -26,18 +26,18 @@  discard block
 block discarded – undo
26 26
 		$this->app = $app;
27 27
 	}
28 28
 
29
-    /**
30
-     * Imports a payload.
31
-     * @param  Writing_On_GitHub_Payload $payload
32
-     *
33
-     * @return string|WP_Error
34
-     */
29
+	/**
30
+	 * Imports a payload.
31
+	 * @param  Writing_On_GitHub_Payload $payload
32
+	 *
33
+	 * @return string|WP_Error
34
+	 */
35 35
 	public function payload( Writing_On_GitHub_Payload $payload ) {
36 36
 
37 37
 		$result = $this->app->api()->fetch()->compare( $payload->get_before_commit_id() );
38 38
 
39 39
 		if ( is_wp_error( $result ) ) {
40
-            /* @var WP_Error $result */
40
+			/* @var WP_Error $result */
41 41
 			return $result;
42 42
 		}
43 43
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	/**
54 54
 	 * import blob by files
55 55
 	 * @param  Writing_On_GitHub_File_Info[] $files
56
-     *
56
+	 *
57 57
 	 * @return string|WP_Error
58 58
 	 */
59 59
 	protected function import_files( $files ) {
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 		$result = $this->app->api()->fetch()->tree_recursive();
93 93
 
94 94
 		if ( is_wp_error( $result ) ) {
95
-            /* @var WP_Error $result */
95
+			/* @var WP_Error $result */
96 96
 			return $result;
97 97
 		}
98 98
 
@@ -105,16 +105,16 @@  discard block
 block discarded – undo
105 105
 		return __( 'Payload processed', 'writing-on-github' );
106 106
 	}
107 107
 
108
-    /**
109
-     * Do compare
110
-     * @param  Writing_On_GitHub_File_Info[]|WP_Error $files
111
-     * @param  int[] &$delete_ids
112
-     *
113
-     * @return string|WP_Error
114
-     */
108
+	/**
109
+	 * Do compare
110
+	 * @param  Writing_On_GitHub_File_Info[]|WP_Error $files
111
+	 * @param  int[] &$delete_ids
112
+	 *
113
+	 * @return string|WP_Error
114
+	 */
115 115
 	protected function compare( $files, &$delete_ids ) {
116 116
 		if ( is_wp_error( $files ) ) {
117
-            /* @var WP_Error $files */
117
+			/* @var WP_Error $files */
118 118
 			return $files;
119 119
 		}
120 120
 
Please login to merge, or discard this patch.
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	 *
23 23
 	 * @param Writing_On_GitHub $app Application container.
24 24
 	 */
25
-	public function __construct( Writing_On_GitHub $app ) {
25
+	public function __construct(Writing_On_GitHub $app) {
26 26
 		$this->app = $app;
27 27
 	}
28 28
 
@@ -32,22 +32,22 @@  discard block
 block discarded – undo
32 32
      *
33 33
      * @return string|WP_Error
34 34
      */
35
-	public function payload( Writing_On_GitHub_Payload $payload ) {
35
+	public function payload(Writing_On_GitHub_Payload $payload) {
36 36
 
37
-		$result = $this->app->api()->fetch()->compare( $payload->get_before_commit_id() );
37
+		$result = $this->app->api()->fetch()->compare($payload->get_before_commit_id());
38 38
 
39
-		if ( is_wp_error( $result ) ) {
39
+		if (is_wp_error($result)) {
40 40
             /* @var WP_Error $result */
41 41
 			return $result;
42 42
 		}
43 43
 
44
-		$result = $this->import_files( $result );
44
+		$result = $this->import_files($result);
45 45
 
46
-		if ( is_wp_error( $result ) ) {
46
+		if (is_wp_error($result)) {
47 47
 			return $files;
48 48
 		}
49 49
 
50
-		return __( 'Payload processed', 'writing-on-github' );
50
+		return __('Payload processed', 'writing-on-github');
51 51
 	}
52 52
 
53 53
 	/**
@@ -56,23 +56,23 @@  discard block
 block discarded – undo
56 56
      *
57 57
 	 * @return string|WP_Error
58 58
 	 */
59
-	protected function import_files( $files ) {
59
+	protected function import_files($files) {
60 60
 
61
-		$error 		= false;
61
+		$error = false;
62 62
 		$delete_ids = false;
63 63
 
64
-		$result = $this->compare( $files, $delete_ids );
64
+		$result = $this->compare($files, $delete_ids);
65 65
 
66
-		if ( is_wp_error( $result ) ) {
66
+		if (is_wp_error($result)) {
67 67
 			return $result;
68 68
 		}
69 69
 
70
-		if ( $delete_ids ) {
70
+		if ($delete_ids) {
71 71
 			foreach ($delete_ids as $id) {
72
-				$result = $this->app->database()->delete_post( $id );
73
-				if ( is_wp_error( $result ) ) {
74
-					if ( $error ) {
75
-						$error->add( $result->get_error_code(), $result->get_error_message() );
72
+				$result = $this->app->database()->delete_post($id);
73
+				if (is_wp_error($result)) {
74
+					if ($error) {
75
+						$error->add($result->get_error_code(), $result->get_error_message());
76 76
 					} else {
77 77
 						$error = $result;
78 78
 					}
@@ -91,18 +91,18 @@  discard block
 block discarded – undo
91 91
 	public function master() {
92 92
 		$result = $this->app->api()->fetch()->tree_recursive();
93 93
 
94
-		if ( is_wp_error( $result ) ) {
94
+		if (is_wp_error($result)) {
95 95
             /* @var WP_Error $result */
96 96
 			return $result;
97 97
 		}
98 98
 
99
-		$result = $this->import_files( $result );
99
+		$result = $this->import_files($result);
100 100
 
101
-		if ( is_wp_error( $result ) ) {
101
+		if (is_wp_error($result)) {
102 102
 			return $result;
103 103
 		}
104 104
 
105
-		return __( 'Payload processed', 'writing-on-github' );
105
+		return __('Payload processed', 'writing-on-github');
106 106
 	}
107 107
 
108 108
     /**
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
      *
113 113
      * @return string|WP_Error
114 114
      */
115
-	protected function compare( $files, &$delete_ids ) {
116
-		if ( is_wp_error( $files ) ) {
115
+	protected function compare($files, &$delete_ids) {
116
+		if (is_wp_error($files)) {
117 117
             /* @var WP_Error $files */
118 118
 			return $files;
119 119
 		}
@@ -123,62 +123,62 @@  discard block
 block discarded – undo
123 123
 
124 124
 		$idsmap = array();
125 125
 
126
-		foreach ( $files as $file ) {
127
-			if ( ! $this->importable_file( $file ) ) {
126
+		foreach ($files as $file) {
127
+			if ( ! $this->importable_file($file)) {
128 128
 				continue;
129 129
 			}
130 130
 
131
-			$blob = $this->app->api()->fetch()->blob( $file );
131
+			$blob = $this->app->api()->fetch()->blob($file);
132 132
 			// network error ?
133
-			if ( ! $blob instanceof Writing_On_GitHub_Blob ) {
133
+			if ( ! $blob instanceof Writing_On_GitHub_Blob) {
134 134
 				continue;
135 135
 			}
136 136
 
137
-			if ( $this->importable_raw_file( $blob ) ) {
138
-				$this->import_raw_file( $blob, $file->status == 'removed' );
137
+			if ($this->importable_raw_file($blob)) {
138
+				$this->import_raw_file($blob, $file->status == 'removed');
139 139
 				continue;
140 140
 			}
141 141
 
142
-			if ( ! $this->importable_blob( $blob ) ) {
142
+			if ( ! $this->importable_blob($blob)) {
143 143
 				continue;
144 144
 			}
145 145
 
146
-			$post = $this->blob_to_post( $blob );
146
+			$post = $this->blob_to_post($blob);
147 147
 
148
-			if ( $file->status == 'removed' ) {
149
-				if ( $blob->id() ) {
148
+			if ($file->status == 'removed') {
149
+				if ($blob->id()) {
150 150
 					$idsmap[$blob->id()] = true;
151 151
 				}
152
-			} elseif ( $post != false ) {
152
+			} elseif ($post != false) {
153 153
 				$posts[] = $post;
154
-				if ( $post->is_new() ) {
154
+				if ($post->is_new()) {
155 155
 					$new[] = $post;
156 156
 				}
157 157
 			}
158 158
 		}
159 159
 
160
-		foreach ( $posts as $post ) {
161
-			if ( $post->id() && isset( $idsmap[ $post->id() ] ) ) {
162
-				unset( $idsmap[ $post->id() ] );
160
+		foreach ($posts as $post) {
161
+			if ($post->id() && isset($idsmap[$post->id()])) {
162
+				unset($idsmap[$post->id()]);
163 163
 			}
164 164
 		}
165 165
 		$delete_ids = array();
166
-		foreach ( $idsmap as $id => $value ) {
166
+		foreach ($idsmap as $id => $value) {
167 167
 			$delete_ids[] = $id;
168 168
 		}
169 169
 
170 170
 		// $this->app->database()->save_posts( $posts, $commit->author_email() );
171 171
 
172
-		$result = $this->app->database()->save_posts( $posts );
172
+		$result = $this->app->database()->save_posts($posts);
173 173
 
174
-		if ( is_wp_error( $result ) ) {
174
+		if (is_wp_error($result)) {
175 175
 			return $result;
176 176
 		}
177 177
 
178
-		if ( ! empty( $new ) ) {
179
-			$result = $this->app->export()->new_posts( $new );
178
+		if ( ! empty($new)) {
179
+			$result = $this->app->export()->new_posts($new);
180 180
 
181
-			if ( is_wp_error( $result ) ) {
181
+			if (is_wp_error($result)) {
182 182
 				return $result;
183 183
 			}
184 184
 		}
@@ -193,12 +193,12 @@  discard block
 block discarded – undo
193 193
 	 *
194 194
 	 * @return bool
195 195
 	 */
196
-	protected function importable_file( Writing_On_GitHub_File_Info $file ) {
196
+	protected function importable_file(Writing_On_GitHub_File_Info $file) {
197 197
 
198 198
 		// only _pages and _posts
199
-		if ( strncasecmp($file->path, '_pages/', strlen('_pages/') ) != 0 &&
200
-			 strncasecmp($file->path, '_posts/', strlen('_posts/') ) != 0 &&
201
-			 strncasecmp($file->path, 'images/', strlen('images/') ) != 0 ) {
199
+		if (strncasecmp($file->path, '_pages/', strlen('_pages/')) != 0 &&
200
+			 strncasecmp($file->path, '_posts/', strlen('_posts/')) != 0 &&
201
+			 strncasecmp($file->path, 'images/', strlen('images/')) != 0) {
202 202
 			return false;
203 203
 		}
204 204
 
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 	 *
218 218
 	 * @return bool
219 219
 	 */
220
-	protected function importable_blob( Writing_On_GitHub_Blob $blob ) {
220
+	protected function importable_blob(Writing_On_GitHub_Blob $blob) {
221 221
 		// global $wpdb;
222 222
 
223 223
 		// // Skip the repo's readme.
@@ -230,20 +230,20 @@  discard block
 block discarded – undo
230 230
 		// 	return false;
231 231
 		// }
232 232
 
233
-		if ( ! $blob->has_frontmatter() ) {
233
+		if ( ! $blob->has_frontmatter()) {
234 234
 			return false;
235 235
 		}
236 236
 
237 237
 		return true;
238 238
 	}
239 239
 
240
-	protected function importable_raw_file( Writing_On_GitHub_Blob $blob ) {
241
-		if ( $blob->has_frontmatter() ) {
240
+	protected function importable_raw_file(Writing_On_GitHub_Blob $blob) {
241
+		if ($blob->has_frontmatter()) {
242 242
 			return false;
243 243
 		}
244 244
 
245 245
 		// only images
246
-		if ( strncasecmp($blob->path(), 'images/', strlen('images/') ) != 0) {
246
+		if (strncasecmp($blob->path(), 'images/', strlen('images/')) != 0) {
247 247
 			return false;
248 248
 		}
249 249
 
@@ -255,16 +255,16 @@  discard block
 block discarded – undo
255 255
 	 * @param  Writing_On_GitHub_Blob $blob
256 256
 	 * @param  bool                   $is_remove
257 257
 	 */
258
-	protected function import_raw_file( Writing_On_GitHub_Blob $blob, $is_remove ) {
258
+	protected function import_raw_file(Writing_On_GitHub_Blob $blob, $is_remove) {
259 259
 		$arr = wp_upload_dir();
260 260
 		$path = $arr['basedir'] . '/writing-on-github/' . $blob->path();
261
-		if ( $is_remove ) {
262
-			if ( file_exists($path) ) {
261
+		if ($is_remove) {
262
+			if (file_exists($path)) {
263 263
 				unlink($path);
264 264
 			}
265 265
 		} else {
266 266
 			$dirname = dirname($path);
267
-			if ( ! file_exists($dirname) ) {
267
+			if ( ! file_exists($dirname)) {
268 268
 				wp_mkdir_p($dirname);
269 269
 			}
270 270
 
@@ -279,57 +279,57 @@  discard block
 block discarded – undo
279 279
 	 *
280 280
 	 * @return Writing_On_GitHub_Post|false
281 281
 	 */
282
-	protected function blob_to_post( Writing_On_GitHub_Blob $blob ) {
283
-		$args = array( 'post_content' => $blob->content_import() );
282
+	protected function blob_to_post(Writing_On_GitHub_Blob $blob) {
283
+		$args = array('post_content' => $blob->content_import());
284 284
 		$meta = $blob->meta();
285 285
 
286 286
 		$id = false;
287 287
 
288
-		if ( ! empty( $meta ) ) {
289
-			if ( array_key_exists( 'layout', $meta ) ) {
288
+		if ( ! empty($meta)) {
289
+			if (array_key_exists('layout', $meta)) {
290 290
 				$args['post_type'] = $meta['layout'];
291
-				unset( $meta['layout'] );
291
+				unset($meta['layout']);
292 292
 			}
293 293
 
294
-			if ( array_key_exists( 'published', $meta ) ) {
294
+			if (array_key_exists('published', $meta)) {
295 295
 				$args['post_status'] = true === $meta['published'] ? 'publish' : 'draft';
296
-				unset( $meta['published'] );
296
+				unset($meta['published']);
297 297
 			}
298 298
 
299
-			if ( array_key_exists( 'post_title', $meta ) ) {
299
+			if (array_key_exists('post_title', $meta)) {
300 300
 				$args['post_title'] = $meta['post_title'];
301
-				unset( $meta['post_title'] );
301
+				unset($meta['post_title']);
302 302
 			}
303 303
 
304
-			if ( array_key_exists( 'post_name', $meta ) ) {
304
+			if (array_key_exists('post_name', $meta)) {
305 305
 				$args['post_name'] = $meta['post_name'];
306
-				unset( $meta['post_name'] );
306
+				unset($meta['post_name']);
307 307
 			}
308 308
 
309
-			if ( array_key_exists( 'ID', $meta ) ) {
309
+			if (array_key_exists('ID', $meta)) {
310 310
 				$id = $args['ID'] = $meta['ID'];
311 311
 				$blob->set_id($id);
312
-				unset( $meta['ID'] );
312
+				unset($meta['ID']);
313 313
 			}
314 314
 		}
315 315
 
316 316
 		$meta['_wogh_sha'] = $blob->sha();
317 317
 
318
-		if ( $id ) {
319
-			$old_sha = get_post_meta( $id, '_wogh_sha', true );
320
-			$old_github_path = get_post_meta( $id, '_wogh_github_path', true );
318
+		if ($id) {
319
+			$old_sha = get_post_meta($id, '_wogh_sha', true);
320
+			$old_github_path = get_post_meta($id, '_wogh_github_path', true);
321 321
 
322 322
 			// dont save post when has same sha
323
-			if ( $old_sha  && $old_sha == $meta['_wogh_sha'] &&
324
-				 $old_github_path && $old_github_path == $blob->path() ) {
323
+			if ($old_sha && $old_sha == $meta['_wogh_sha'] &&
324
+				 $old_github_path && $old_github_path == $blob->path()) {
325 325
 				return false;
326 326
 			}
327 327
 		}
328 328
 
329
-		$post = new Writing_On_GitHub_Post( $args, $this->app->api() );
330
-		$post->set_old_github_path( $blob->path() );
331
-		$post->set_meta( $meta );
332
-		$blob->set_id( $post->id() );
329
+		$post = new Writing_On_GitHub_Post($args, $this->app->api());
330
+		$post->set_old_github_path($blob->path());
331
+		$post->set_meta($meta);
332
+		$blob->set_id($post->id());
333 333
 
334 334
 		return $post;
335 335
 	}
Please login to merge, or discard this patch.
lib/request.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	 *
35 35
 	 * @param Writing_On_GitHub $app Application container.
36 36
 	 */
37
-	public function __construct( Writing_On_GitHub $app ) {
37
+	public function __construct(Writing_On_GitHub $app) {
38 38
 		$this->app = $app;
39 39
 	}
40 40
 
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
 		$this->raw_data = $this->read_raw_data();
50 50
 
51 51
 		// Validate request secret.
52
-		$hash = hash_hmac( 'sha1', $this->raw_data, $this->secret() );
53
-		if ( 'sha1=' . $hash !== $headers['X-Hub-Signature'] ) {
52
+		$hash = hash_hmac('sha1', $this->raw_data, $this->secret());
53
+		if ('sha1=' . $hash !== $headers['X-Hub-Signature']) {
54 54
 			return false;
55 55
 		}
56 56
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 * @return Writing_On_GitHub_Payload
91 91
 	 */
92 92
 	public function payload() {
93
-		return new Writing_On_GitHub_Payload( $this->app, $this->raw_data );
93
+		return new Writing_On_GitHub_Payload($this->app, $this->raw_data);
94 94
 	}
95 95
 
96 96
 	/**
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
 	 * @return array
102 102
 	 */
103 103
 	protected function headers() {
104
-		if ( ! empty( $this->headers ) ) {
104
+		if ( ! empty($this->headers)) {
105 105
 			return $this->headers;
106 106
 		}
107 107
 
108
-		if ( function_exists( 'getallheaders' ) ) {
108
+		if (function_exists('getallheaders')) {
109 109
 
110 110
 			$this->headers = getallheaders();
111 111
 			return $this->headers;
@@ -115,9 +115,9 @@  discard block
 block discarded – undo
115 115
 		 * @see http://www.php.net/manual/en/function.getallheaders.php
116 116
 		 */
117 117
 		$this->headers = array();
118
-		foreach ( $_SERVER as $name => $value ) {
119
-			if ( 'HTTP_' === substr( $name, 0, 5 ) ) {
120
-				$this->headers[ str_replace( ' ', '-', ucwords( strtolower( str_replace( '_', ' ', substr( $name, 5 ) ) ) ) ) ] = $value;
118
+		foreach ($_SERVER as $name => $value) {
119
+			if ('HTTP_' === substr($name, 0, 5)) {
120
+				$this->headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
121 121
 			}
122 122
 		}
123 123
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	 * @return string
131 131
 	 */
132 132
 	protected function read_raw_data() {
133
-		return file_get_contents( 'php://input' );
133
+		return file_get_contents('php://input');
134 134
 	}
135 135
 
136 136
 	/**
@@ -139,6 +139,6 @@  discard block
 block discarded – undo
139 139
 	 * @return string
140 140
 	 */
141 141
 	protected function secret() {
142
-		return get_option( 'wogh_secret' );
142
+		return get_option('wogh_secret');
143 143
 	}
144 144
 }
Please login to merge, or discard this patch.