Code Duplication    Length = 3-3 lines in 3 locations

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

@@ 2058-2060 (lines=3) @@
2055
	 * @return bool
2056
	 */
2057
	public static function validate_alphanum( $value = '', $request, $param ) {
2058
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/[a-z0-9]+/i', $value ) ) ) {
2059
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) );
2060
		}
2061
		return true;
2062
	}
2063
@@ 2183-2185 (lines=3) @@
2180
	 * @return bool
2181
	 */
2182
	public static function validate_custom_service_id( $value = '', $request, $param ) {
2183
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) {
2184
			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 ) );
2185
		}
2186
2187
		if ( ! class_exists( 'Sharing_Service' ) && ! @include( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) {
2188
			return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) );
@@ 2212-2214 (lines=3) @@
2209
	 * @return bool
2210
	 */
2211
	public static function validate_twitter_username( $value = '', $request, $param ) {
2212
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) {
2213
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) );
2214
		}
2215
		return true;
2216
	}
2217