Code Duplication    Length = 3-3 lines in 3 locations

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

@@ 2679-2681 (lines=3) @@
2676
	 * @return bool|WP_Error
2677
	 */
2678
	public static function validate_alphanum( $value = '', $request, $param ) {
2679
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^[a-z0-9]+$/i', $value ) ) ) {
2680
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) );
2681
		}
2682
		return true;
2683
	}
2684
@@ 2839-2841 (lines=3) @@
2836
	 * @return bool|WP_Error
2837
	 */
2838
	public static function validate_custom_service_id( $value = '', $request, $param ) {
2839
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) {
2840
			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 ) );
2841
		}
2842
2843
		if ( ! class_exists( 'Sharing_Service' ) && ! include_once( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) {
2844
			return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) );
@@ 2868-2870 (lines=3) @@
2865
	 * @return bool|WP_Error
2866
	 */
2867
	public static function validate_twitter_username( $value = '', $request, $param ) {
2868
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) {
2869
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) );
2870
		}
2871
		return true;
2872
	}
2873