Code Duplication    Length = 3-3 lines in 3 locations

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

@@ 2831-2833 (lines=3) @@
2828
2829
			// If it's an associative array, use the keys to check that the value is among those admitted.
2830
			$enum = ( count( array_filter( array_keys( $args['enum'] ), 'is_string' ) ) > 0 ) ? array_keys( $args['enum'] ) : $args['enum'];
2831
			if ( ! in_array( $value, $enum ) ) {
2832
				return new WP_Error( 'invalid_param_value', sprintf(
2833
					/* Translators: first variable is the parameter passed to endpoint that holds the list item, the second is a list of admitted values. */
2834
					esc_html__( '%1$s must be one of %2$s', 'jetpack' ), $param, implode( ', ', $enum )
2835
				) );
2836
			}
@@ 2859-2861 (lines=3) @@
2856
2857
		$modules = Jetpack::get_available_modules();
2858
2859
		if ( count( array_intersect( $value, $modules ) ) != count( $value ) ) {
2860
			return new WP_Error( 'invalid_param_value', sprintf( esc_html__( '%s must be a list of valid modules', 'jetpack' ), $param ) );
2861
		}
2862
2863
		return true;
2864
	}
@@ 3048-3050 (lines=3) @@
3045
		$sharer = new Sharing_Service();
3046
		$services = array_keys( $sharer->get_all_services() );
3047
3048
		if ( ! empty( $value ) && ! in_array( $value, $services ) ) {
3049
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s is not a registered custom sharing service.', 'jetpack' ), $param ) );
3050
		}
3051
3052
		return true;
3053
	}