Code Duplication    Length = 8-9 lines in 4 locations

core/libraries/batch/BatchRequestProcessor.php 4 locations

@@ 59-66 (lines=8) @@
56
			$obj = $this->instantiate_batch_job_handler_from_classname( $batch_job_handler_class );
57
			$this->_job_parameters = new JobParameters( $this->_job_id, $batch_job_handler_class, $request_data );
58
			$response = $obj->create_job( $this->_job_parameters );
59
			if( ! $response instanceof JobStepResponse ) {
60
				throw new BatchRequestException(
61
					sprintf(
62
						__( 'The class implementing JobHandlerInterface did not return a JobStepResponse when create_job was called with %1$s. It needs to return one or throw an Exception', 'event_espresso' ),
63
						wp_json_encode( $request_data )
64
					)
65
				);
66
			}
67
			$success = $this->_job_parameters->save( true );
68
			if( ! $success ) {
69
				throw new BatchRequestException(
@@ 68-76 (lines=9) @@
65
				);
66
			}
67
			$success = $this->_job_parameters->save( true );
68
			if( ! $success ) {
69
				throw new BatchRequestException(
70
					sprintf(
71
						__('Could not save job %1$s to the Wordpress Options table. These were the arguments used: %2$s', 'event_espresso'),
72
						$this->_job_id,
73
						wp_json_encode( $request_data )
74
					)
75
				);
76
			}
77
		} catch( \Exception $e ) {
78
			$response = $this->_get_error_response( $e, 'create_job' );
79
		}
@@ 100-107 (lines=8) @@
97
			$handler_obj = $this->instantiate_batch_job_handler_from_classname( $this->_job_parameters->classname() );
98
			//continue it
99
			$response = $handler_obj->continue_job( $this->_job_parameters, $batch_size );
100
			if( ! $response instanceof JobStepResponse ) {
101
				throw new BatchRequestException(
102
					sprintf(
103
						__( 'The class implementing JobHandlerInterface did not return a JobStepResponse when continue_job was called with job %1$s. It needs to return one or throw an Exception', 'event_espresso' ),
104
						$this->_job_id
105
					)
106
				);
107
			}
108
			$this->_job_parameters->save();
109
		} catch( \Exception $e ) {
110
			$response = $this->_get_error_response( $e, 'continue_job' );
@@ 162-169 (lines=8) @@
159
			$handler_obj = $this->instantiate_batch_job_handler_from_classname( $job_parameters->classname() );
160
			//continue it
161
			$response = $handler_obj->cleanup_job( $job_parameters );
162
			if( ! $response instanceof JobStepResponse ) {
163
				throw new BatchRequestException(
164
					sprintf(
165
						__( 'The class implementing JobHandlerInterface did not return a JobStepResponse when cleanup_job was called with job %1$s. It needs to return one or throw an Exception', 'event_espresso' ),
166
						$this->_job_id
167
					)
168
				);
169
			}
170
			$job_parameters->set_status( JobParameters::status_cleaned_up );
171
			$job_parameters->delete();
172
			return $response;