Code Duplication    Length = 3-3 lines in 3 locations

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

@@ 1759-1761 (lines=3) @@
1756
	 * @return bool
1757
	 */
1758
	public static function validate_alphanum( $value = '', $request, $param ) {
1759
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/[a-z0-9]+/i', $value ) ) ) {
1760
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) );
1761
		}
1762
		return true;
1763
	}
1764
@@ 1901-1903 (lines=3) @@
1898
	 * @return bool
1899
	 */
1900
	public static function validate_custom_service_id( $value = '', $request, $param ) {
1901
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) {
1902
			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 ) );
1903
		}
1904
1905
		if ( ! class_exists( 'Sharing_Service' ) && ! @include( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) {
1906
			return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) );
@@ 1930-1932 (lines=3) @@
1927
	 * @return bool
1928
	 */
1929
	public static function validate_twitter_username( $value = '', $request, $param ) {
1930
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) {
1931
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) );
1932
		}
1933
		return true;
1934
	}
1935