Code Duplication    Length = 4-6 lines in 2 locations

src/wp-includes/rest-api.php 2 locations

@@ 1058-1063 (lines=6) @@
1055
			}
1056
		}
1057
	}
1058
	if ( ! empty( $args['enum'] ) ) {
1059
		if ( ! in_array( $value, $args['enum'], true ) ) {
1060
			/* translators: 1: parameter, 2: list of valid values */
1061
			return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s is not one of %2$s.' ), $param, implode( ', ', $args['enum'] ) ) );
1062
		}
1063
	}
1064
1065
	if ( in_array( $args['type'], array( 'integer', 'number' ) ) && ! is_numeric( $value ) ) {
1066
		/* translators: 1: parameter, 2: type name */
@@ 1065-1068 (lines=4) @@
1062
		}
1063
	}
1064
1065
	if ( in_array( $args['type'], array( 'integer', 'number' ) ) && ! is_numeric( $value ) ) {
1066
		/* translators: 1: parameter, 2: type name */
1067
		return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s is not of type %2$s.' ), $param, $args['type'] ) );
1068
	}
1069
1070
	if ( 'integer' === $args['type'] && round( floatval( $value ) ) !== floatval( $value ) ) {
1071
		/* translators: 1: parameter, 2: type name */