Code Duplication    Length = 3-3 lines in 3 locations

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

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