Code Duplication    Length = 3-3 lines in 3 locations

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

@@ 2376-2378 (lines=3) @@
2373
2374
			// If it's an associative array, use the keys to check that the value is among those admitted.
2375
			$enum = ( count( array_filter( array_keys( $args['enum'] ), 'is_string' ) ) > 0 ) ? array_keys( $args['enum'] ) : $args['enum'];
2376
			if ( ! in_array( $value, $enum ) ) {
2377
				return new WP_Error( 'invalid_param_value', sprintf(
2378
					/* Translators: first variable is the parameter passed to endpoint that holds the list item, the second is a list of admitted values. */
2379
					esc_html__( '%1$s must be one of %2$s', 'jetpack' ), $param, implode( ', ', $enum )
2380
				) );
2381
			}
@@ 2404-2406 (lines=3) @@
2401
2402
		$modules = Jetpack::get_available_modules();
2403
2404
		if ( count( array_intersect( $value, $modules ) ) != count( $value ) ) {
2405
			return new WP_Error( 'invalid_param_value', sprintf( esc_html__( '%s must be a list of valid modules', 'jetpack' ), $param ) );
2406
		}
2407
2408
		return true;
2409
	}
@@ 2593-2595 (lines=3) @@
2590
		$sharer = new Sharing_Service();
2591
		$services = array_keys( $sharer->get_all_services() );
2592
2593
		if ( ! empty( $value ) && ! in_array( $value, $services ) ) {
2594
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s is not a registered custom sharing service.', 'jetpack' ), $param ) );
2595
		}
2596
2597
		return true;
2598
	}