Code Duplication    Length = 3-3 lines in 3 locations

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

@@ 2362-2364 (lines=3) @@
2359
	 * @return bool|WP_Error
2360
	 */
2361
	public static function validate_alphanum( $value = '', $request, $param ) {
2362
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^[a-z0-9]+$/i', $value ) ) ) {
2363
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) );
2364
		}
2365
		return true;
2366
	}
2367
@@ 2522-2524 (lines=3) @@
2519
	 * @return bool|WP_Error
2520
	 */
2521
	public static function validate_custom_service_id( $value = '', $request, $param ) {
2522
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) {
2523
			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 ) );
2524
		}
2525
2526
		if ( ! class_exists( 'Sharing_Service' ) && ! include_once( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) {
2527
			return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) );
@@ 2551-2553 (lines=3) @@
2548
	 * @return bool|WP_Error
2549
	 */
2550
	public static function validate_twitter_username( $value = '', $request, $param ) {
2551
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) {
2552
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) );
2553
		}
2554
		return true;
2555
	}
2556