Code Duplication    Length = 18-18 lines in 2 locations

lib/controller.php 2 locations

@@ 149-166 (lines=18) @@
146
	 *
147
	 * @return boolean
148
	 */
149
	public function export_post( $post_id ) {
150
		if ( ! $this->app->semaphore()->is_open() ) {
151
			return $this->app->response()->error( new WP_Error(
152
				'semaphore_locked',
153
				sprintf( __( '%s : Semaphore is locked, import/export already in progress.', 'wordpress-github-sync' ), 'Controller::export_post()' )
154
			) );
155
		}
156
157
		$this->app->semaphore()->lock();
158
		$result = $this->app->export()->update( $post_id );
159
		$this->app->semaphore()->unlock();
160
161
		if ( is_wp_error( $result ) ) {
162
			return $this->app->response()->error( $result );
163
		}
164
165
		return $this->app->response()->success( $result );
166
	}
167
168
	/**
169
	 * Removes the post from the tree.
@@ 177-194 (lines=18) @@
174
	 *
175
	 * @return boolean
176
	 */
177
	public function delete_post( $post_id ) {
178
		if ( ! $this->app->semaphore()->is_open() ) {
179
			return $this->app->response()->error( new WP_Error(
180
				'semaphore_locked',
181
				sprintf( __( '%s : Semaphore is locked, import/export already in progress.', 'wordpress-github-sync' ), 'Controller::delete_post()' )
182
			) );
183
		}
184
185
		$this->app->semaphore()->lock();
186
		$result = $this->app->export()->delete( $post_id );
187
		$this->app->semaphore()->unlock();
188
189
		if ( is_wp_error( $result ) ) {
190
			return $this->app->response()->error( $result );
191
		}
192
193
		return $this->app->response()->success( $result );
194
	}
195
196
	/**
197
	 * Indicates we're running our own AJAX hook