Code Duplication    Length = 3-3 lines in 3 locations

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

@@ 1937-1939 (lines=3) @@
1934
	 * @return bool
1935
	 */
1936
	public static function validate_alphanum( $value = '', $request, $param ) {
1937
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/[a-z0-9]+/i', $value ) ) ) {
1938
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) );
1939
		}
1940
		return true;
1941
	}
1942
@@ 2044-2046 (lines=3) @@
2041
	 * @return bool
2042
	 */
2043
	public static function validate_custom_service_id( $value = '', $request, $param ) {
2044
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) {
2045
			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 ) );
2046
		}
2047
2048
		if ( ! class_exists( 'Sharing_Service' ) && ! @include( JETPACK__PLUGIN_DIR . 'modules/sharing/sharing-service.php' ) ) {
2049
			return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) );
@@ 2073-2075 (lines=3) @@
2070
	 * @return bool
2071
	 */
2072
	public static function validate_twitter_username( $value = '', $request, $param ) {
2073
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) {
2074
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) );
2075
		}
2076
		return true;
2077
	}
2078