Code Duplication    Length = 3-3 lines in 3 locations

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

@@ 1908-1910 (lines=3) @@
1905
	 * @return bool
1906
	 */
1907
	public static function validate_alphanum( $value = '', $request, $param ) {
1908
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/[a-z0-9]+/i', $value ) ) ) {
1909
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) );
1910
		}
1911
		return true;
1912
	}
1913
@@ 2015-2017 (lines=3) @@
2012
	 * @return bool
2013
	 */
2014
	public static function validate_custom_service_id( $value = '', $request, $param ) {
2015
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) {
2016
			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 ) );
2017
		}
2018
2019
		if ( ! class_exists( 'Sharing_Service' ) && ! @include( JETPACK__PLUGIN_DIR . 'modules/sharing/sharing-service.php' ) ) {
2020
			return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) );
@@ 2044-2046 (lines=3) @@
2041
	 * @return bool
2042
	 */
2043
	public static function validate_twitter_username( $value = '', $request, $param ) {
2044
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) {
2045
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) );
2046
		}
2047
		return true;
2048
	}
2049