Code Duplication    Length = 3-3 lines in 3 locations

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

@@ 2400-2402 (lines=3) @@
2397
	 * @return bool|WP_Error
2398
	 */
2399
	public static function validate_alphanum( $value = '', $request, $param ) {
2400
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^[a-z0-9]+$/i', $value ) ) ) {
2401
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) );
2402
		}
2403
		return true;
2404
	}
2405
@@ 2560-2562 (lines=3) @@
2557
	 * @return bool|WP_Error
2558
	 */
2559
	public static function validate_custom_service_id( $value = '', $request, $param ) {
2560
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) {
2561
			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 ) );
2562
		}
2563
2564
		if ( ! class_exists( 'Sharing_Service' ) && ! include_once( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) {
2565
			return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) );
@@ 2589-2591 (lines=3) @@
2586
	 * @return bool|WP_Error
2587
	 */
2588
	public static function validate_twitter_username( $value = '', $request, $param ) {
2589
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) {
2590
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) );
2591
		}
2592
		return true;
2593
	}
2594