Code Duplication    Length = 3-7 lines in 3 locations

_inc/lib/core-api/class.jetpack-core-api-module-endpoints.php 3 locations

@@ 114-120 (lines=7) @@
111
			$module_slug = $request;
112
		}
113
114
		if ( ! Jetpack::is_module( $module_slug ) ) {
115
			return new WP_Error(
116
				'not_found',
117
				esc_html__( 'The requested Jetpack module was not found.', 'jetpack' ),
118
				array( 'status' => 404 )
119
			);
120
		}
121
122
		if ( ! Jetpack::is_module_active( $module_slug ) ) {
123
			return new WP_Error(
@@ 62-68 (lines=7) @@
59
			$module_slug = $request;
60
		}
61
62
		if ( ! Jetpack::is_module( $module_slug ) ) {
63
			return new WP_Error(
64
				'not_found',
65
				esc_html__( 'The requested Jetpack module was not found.', 'jetpack' ),
66
				array( 'status' => 404 )
67
			);
68
		}
69
70
		if ( Jetpack::activate_module( $module_slug, false, false ) ) {
71
			return rest_ensure_response( array(
@@ 465-467 (lines=3) @@
462
			// It will not be passed. It's just checked in this method to pass that method a string or array.
463
			$request['slug'] = 'any';
464
		} else {
465
			if ( ! Jetpack::is_module( $request['slug'] ) ) {
466
				return new WP_Error( 'not_found', esc_html__( 'The requested Jetpack module was not found.', 'jetpack' ), array( 'status' => 404 ) );
467
			}
468
469
			if ( ! Jetpack::is_module_active( $request['slug'] ) ) {
470
				return new WP_Error( 'inactive', esc_html__( 'The requested Jetpack module is inactive.', 'jetpack' ), array( 'status' => 409 ) );