Code Duplication    Length = 3-3 lines in 3 locations

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

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