Code Duplication    Length = 3-3 lines in 3 locations

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

@@ 2423-2425 (lines=3) @@
2420
	 * @return bool|WP_Error
2421
	 */
2422
	public static function validate_alphanum( $value = '', $request, $param ) {
2423
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^[a-z0-9]+$/i', $value ) ) ) {
2424
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) );
2425
		}
2426
		return true;
2427
	}
2428
@@ 2583-2585 (lines=3) @@
2580
	 * @return bool|WP_Error
2581
	 */
2582
	public static function validate_custom_service_id( $value = '', $request, $param ) {
2583
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) {
2584
			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 ) );
2585
		}
2586
2587
		if ( ! class_exists( 'Sharing_Service' ) && ! include_once( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) {
2588
			return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) );
@@ 2612-2614 (lines=3) @@
2609
	 * @return bool|WP_Error
2610
	 */
2611
	public static function validate_twitter_username( $value = '', $request, $param ) {
2612
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) {
2613
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) );
2614
		}
2615
		return true;
2616
	}
2617