Code Duplication    Length = 3-3 lines in 4 locations

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

@@ 2103-2105 (lines=3) @@
2100
	 * @return bool|WP_Error
2101
	 */
2102
	public static function validate_alphanum( $value = '', $request, $param ) {
2103
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^[a-z0-9]+$/i', $value ) ) ) {
2104
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) );
2105
		}
2106
		return true;
2107
	}
2108
@@ 2121-2123 (lines=3) @@
2118
	 * @return bool|WP_Error
2119
	 */
2120
	public static function validate_verification_service( $value = '', $request, $param ) {
2121
		if ( ! empty( $value ) && ! ( is_string( $value ) && ( preg_match( '/^[a-z0-9_-]+$/i', $value ) || preg_match( '#^<meta name="([a-z0-9_\-.:]+)?" content="([a-z0-9_-]+)?" />$#i', $value ) ) ) ) {
2122
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string or a verification tag.', 'jetpack' ), $param ) );
2123
		}
2124
		return true;
2125
	}
2126
@@ 2263-2265 (lines=3) @@
2260
	 * @return bool|WP_Error
2261
	 */
2262
	public static function validate_custom_service_id( $value = '', $request, $param ) {
2263
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) {
2264
			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 ) );
2265
		}
2266
2267
		if ( ! class_exists( 'Sharing_Service' ) && ! include_once( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) {
2268
			return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) );
@@ 2292-2294 (lines=3) @@
2289
	 * @return bool|WP_Error
2290
	 */
2291
	public static function validate_twitter_username( $value = '', $request, $param ) {
2292
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) {
2293
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) );
2294
		}
2295
		return true;
2296
	}
2297