Code Duplication    Length = 3-3 lines in 3 locations

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

@@ 1923-1925 (lines=3) @@
1920
	 * @return bool
1921
	 */
1922
	public static function validate_alphanum( $value = '', $request, $param ) {
1923
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/[a-z0-9]+/i', $value ) ) ) {
1924
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) );
1925
		}
1926
		return true;
1927
	}
1928
@@ 2030-2032 (lines=3) @@
2027
	 * @return bool
2028
	 */
2029
	public static function validate_custom_service_id( $value = '', $request, $param ) {
2030
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) {
2031
			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 ) );
2032
		}
2033
2034
		if ( ! class_exists( 'Sharing_Service' ) && ! @include( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) {
2035
			return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) );
@@ 2059-2061 (lines=3) @@
2056
	 * @return bool
2057
	 */
2058
	public static function validate_twitter_username( $value = '', $request, $param ) {
2059
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) {
2060
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) );
2061
		}
2062
		return true;
2063
	}
2064