Code Duplication    Length = 3-3 lines in 3 locations

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

@@ 1998-2000 (lines=3) @@
1995
1996
			// If it's an associative array, use the keys to check that the value is among those admitted.
1997
			$enum = ( count( array_filter( array_keys( $args['enum'] ), 'is_string' ) ) > 0 ) ? array_keys( $args['enum'] ) : $args['enum'];
1998
			if ( ! in_array( $value, $enum ) ) {
1999
				return new WP_Error( 'invalid_param_value', sprintf(
2000
					/* Translators: first variable is the parameter passed to endpoint that holds the list item, the second is a list of admitted values. */
2001
					esc_html__( '%1$s must be one of %2$s', 'jetpack' ), $param, implode( ', ', $enum )
2002
				) );
2003
			}
@@ 2026-2028 (lines=3) @@
2023
2024
		$modules = Jetpack::get_available_modules();
2025
2026
		if ( count( array_intersect( $value, $modules ) ) != count( $value ) ) {
2027
			return new WP_Error( 'invalid_param_value', sprintf( esc_html__( '%s must be a list of valid modules', 'jetpack' ), $param ) );
2028
		}
2029
2030
		return true;
2031
	}
@@ 2215-2217 (lines=3) @@
2212
		$sharer = new Sharing_Service();
2213
		$services = array_keys( $sharer->get_all_services() );
2214
2215
		if ( ! empty( $value ) && ! in_array( $value, $services ) ) {
2216
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s is not a registered custom sharing service.', 'jetpack' ), $param ) );
2217
		}
2218
2219
		return true;
2220
	}