Code Duplication    Length = 3-3 lines in 3 locations

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

@@ 2730-2732 (lines=3) @@
2727
	 * @return bool|WP_Error
2728
	 */
2729
	public static function validate_alphanum( $value = '', $request, $param ) {
2730
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^[a-z0-9]+$/i', $value ) ) ) {
2731
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) );
2732
		}
2733
		return true;
2734
	}
2735
@@ 2890-2892 (lines=3) @@
2887
	 * @return bool|WP_Error
2888
	 */
2889
	public static function validate_custom_service_id( $value = '', $request, $param ) {
2890
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) {
2891
			return new WP_Error( 'invalid_param', sprintf( esc_html__( "%s must be a string prefixed with 'custom-' and followed by a numeric ID.", 'jetpack' ), $param ) );
2892
		}
2893
2894
		if ( ! class_exists( 'Sharing_Service' ) && ! include_once( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) {
2895
			return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) );
@@ 2919-2921 (lines=3) @@
2916
	 * @return bool|WP_Error
2917
	 */
2918
	public static function validate_twitter_username( $value = '', $request, $param ) {
2919
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) {
2920
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) );
2921
		}
2922
		return true;
2923
	}
2924