Code Duplication    Length = 3-3 lines in 3 locations

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

@@ 2683-2685 (lines=3) @@
2680
2681
			// If it's an associative array, use the keys to check that the value is among those admitted.
2682
			$enum = ( count( array_filter( array_keys( $args['enum'] ), 'is_string' ) ) > 0 ) ? array_keys( $args['enum'] ) : $args['enum'];
2683
			if ( ! in_array( $value, $enum ) ) {
2684
				return new WP_Error( 'invalid_param_value', sprintf(
2685
					/* Translators: first variable is the parameter passed to endpoint that holds the list item, the second is a list of admitted values. */
2686
					esc_html__( '%1$s must be one of %2$s', 'jetpack' ), $param, implode( ', ', $enum )
2687
				) );
2688
			}
@@ 2711-2713 (lines=3) @@
2708
2709
		$modules = Jetpack::get_available_modules();
2710
2711
		if ( count( array_intersect( $value, $modules ) ) != count( $value ) ) {
2712
			return new WP_Error( 'invalid_param_value', sprintf( esc_html__( '%s must be a list of valid modules', 'jetpack' ), $param ) );
2713
		}
2714
2715
		return true;
2716
	}
@@ 2900-2902 (lines=3) @@
2897
		$sharer = new Sharing_Service();
2898
		$services = array_keys( $sharer->get_all_services() );
2899
2900
		if ( ! empty( $value ) && ! in_array( $value, $services ) ) {
2901
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s is not a registered custom sharing service.', 'jetpack' ), $param ) );
2902
		}
2903
2904
		return true;
2905
	}