Code Duplication    Length = 3-3 lines in 4 locations

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

@@ 2045-2047 (lines=3) @@
2042
	 * @return bool|WP_Error
2043
	 */
2044
	public static function validate_alphanum( $value = '', $request, $param ) {
2045
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^[a-z0-9]+$/i', $value ) ) ) {
2046
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) );
2047
		}
2048
		return true;
2049
	}
2050
@@ 2063-2065 (lines=3) @@
2060
	 * @return bool|WP_Error
2061
	 */
2062
	public static function validate_verification_service( $value = '', $request, $param ) {
2063
		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 ) ) ) ) {
2064
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string or a verification tag.', 'jetpack' ), $param ) );
2065
		}
2066
		return true;
2067
	}
2068
@@ 2205-2207 (lines=3) @@
2202
	 * @return bool|WP_Error
2203
	 */
2204
	public static function validate_custom_service_id( $value = '', $request, $param ) {
2205
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) {
2206
			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 ) );
2207
		}
2208
2209
		if ( ! class_exists( 'Sharing_Service' ) && ! include_once( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) {
2210
			return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) );
@@ 2234-2236 (lines=3) @@
2231
	 * @return bool|WP_Error
2232
	 */
2233
	public static function validate_twitter_username( $value = '', $request, $param ) {
2234
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) {
2235
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) );
2236
		}
2237
		return true;
2238
	}
2239