Code Duplication    Length = 3-3 lines in 3 locations

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

@@ 2878-2880 (lines=3) @@
2875
	 * @return bool|WP_Error
2876
	 */
2877
	public static function validate_alphanum( $value, $request, $param ) {
2878
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^[a-z0-9]+$/i', $value ) ) ) {
2879
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) );
2880
		}
2881
		return true;
2882
	}
2883
@@ 3038-3040 (lines=3) @@
3035
	 * @return bool|WP_Error
3036
	 */
3037
	public static function validate_custom_service_id( $value, $request, $param ) {
3038
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) {
3039
			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 ) );
3040
		}
3041
3042
		if ( ! class_exists( 'Sharing_Service' ) && ! include_once( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) {
3043
			return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) );
@@ 3067-3069 (lines=3) @@
3064
	 * @return bool|WP_Error
3065
	 */
3066
	public static function validate_twitter_username( $value, $request, $param ) {
3067
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) {
3068
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) );
3069
		}
3070
		return true;
3071
	}
3072