Code Duplication    Length = 3-3 lines in 3 locations

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

@@ 1902-1904 (lines=3) @@
1899
	 * @return bool
1900
	 */
1901
	public static function validate_alphanum( $value = '', $request, $param ) {
1902
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/[a-z0-9]+/i', $value ) ) ) {
1903
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) );
1904
		}
1905
		return true;
1906
	}
1907
@@ 2009-2011 (lines=3) @@
2006
	 * @return bool
2007
	 */
2008
	public static function validate_custom_service_id( $value = '', $request, $param ) {
2009
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) {
2010
			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 ) );
2011
		}
2012
2013
		if ( ! class_exists( 'Sharing_Service' ) && ! @include( JETPACK__PLUGIN_DIR . 'modules/sharing/sharing-service.php' ) ) {
2014
			return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) );
@@ 2038-2040 (lines=3) @@
2035
	 * @return bool
2036
	 */
2037
	public static function validate_twitter_username( $value = '', $request, $param ) {
2038
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) {
2039
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) );
2040
		}
2041
		return true;
2042
	}
2043