Code Duplication    Length = 3-5 lines in 4 locations

includes/vendor/wp-api-functions.php 3 locations

@@ 91-95 (lines=5) @@
88
		}
89
		$args = $attributes['args'][ $param ];
90
91
		if ( ! empty( $args['enum'] ) ) {
92
			if ( ! in_array( $value, $args['enum'] ) ) {
93
				return new WP_Error( 'rest_invalid_param', sprintf( __( '%s is not one of %s' ), $param, implode( ', ', $args['enum'] ) ) );
94
			}
95
		}
96
97
		if ( 'integer' === $args['type'] && ! is_numeric( $value ) ) {
98
			return new WP_Error( 'rest_invalid_param', sprintf( __( '%s is not of type %s' ), $param, 'integer' ) );
@@ 97-99 (lines=3) @@
94
			}
95
		}
96
97
		if ( 'integer' === $args['type'] && ! is_numeric( $value ) ) {
98
			return new WP_Error( 'rest_invalid_param', sprintf( __( '%s is not of type %s' ), $param, 'integer' ) );
99
		}
100
101
		if ( 'string' === $args['type'] && ! is_string( $value ) ) {
102
			return new WP_Error( 'rest_invalid_param', sprintf( __( '%s is not of type %s' ), $param, 'string' ) );
@@ 101-103 (lines=3) @@
98
			return new WP_Error( 'rest_invalid_param', sprintf( __( '%s is not of type %s' ), $param, 'integer' ) );
99
		}
100
101
		if ( 'string' === $args['type'] && ! is_string( $value ) ) {
102
			return new WP_Error( 'rest_invalid_param', sprintf( __( '%s is not of type %s' ), $param, 'string' ) );
103
		}
104
105
		if ( isset( $args['format'] ) ) {
106
			switch ( $args['format'] ) {

includes/vendor/wp-rest-functions.php 1 location

@@ 167-171 (lines=5) @@
164
		}
165
		$args = $attributes['args'][ $param ];
166
167
		if ( ! empty( $args['enum'] ) ) {
168
			if ( ! in_array( $value, $args['enum'] ) ) {
169
				return new WP_Error( 'rest_invalid_param', sprintf( __( '%s is not one of %s', 'woocommerce' ), $param, implode( ', ', $args['enum'] ) ) );
170
			}
171
		}
172
173
		if ( 'integer' === $args['type'] && ! is_numeric( $value ) ) {
174
			return new WP_Error( 'rest_invalid_param', sprintf( __( '%s is not of type %s', 'woocommerce' ), $param, 'integer' ) );