Code Duplication    Length = 3-10 lines in 3 locations

_inc/lib/core-api/class.jetpack-core-api-module-endpoints.php 1 location

@@ 228-237 (lines=10) @@
225
	 */
226
	public static function activate_modules( $request ) {
227
228
		if (
229
			! isset( $request['modules'] )
230
			|| ! is_array( $request['modules'] )
231
		) {
232
			return new WP_Error(
233
				'not_found',
234
				esc_html__( 'The requested Jetpack module was not found.', 'jetpack' ),
235
				array( 'status' => 404 )
236
			);
237
		}
238
239
		$activated = array();
240
		$failed = array();

modules/widgets/class-jetpack-instagram-widget.php 1 location

@@ 232-234 (lines=3) @@
229
		}
230
231
		$data = json_decode( wp_remote_retrieve_body( $result ), true );
232
		if ( ! isset( $data['images'] ) || ! is_array( $data['images'] ) ) {
233
			return new WP_Error( 'missing_images', esc_html__( 'The images were missing', 'jetpack' ), $response_code );
234
		}
235
236
		set_transient( $transient_key, $data, HOUR_IN_SECONDS );
237
		return $data;

_inc/lib/class.core-rest-api-endpoints.php 1 location

@@ 2810-2812 (lines=3) @@
2807
	 * @return bool|WP_Error
2808
	 */
2809
	public static function validate_services( $value, $request, $param ) {
2810
		if ( ! is_array( $value ) || ! isset( $value['visible'] ) || ! isset( $value['hidden'] ) ) {
2811
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an array with visible and hidden items.', 'jetpack' ), $param ) );
2812
		}
2813
2814
		// Allow to clear everything.
2815
		if ( empty( $value['visible'] ) && empty( $value['hidden'] ) ) {