Code Duplication    Length = 3-3 lines in 3 locations

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

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