Code Duplication    Length = 3-3 lines in 4 locations

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

@@ 1774-1776 (lines=3) @@
1771
	 * @return bool
1772
	 */
1773
	public static function validate_alphanum( $value = '', $request, $param ) {
1774
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^[a-z0-9]+$/i', $value ) ) ) {
1775
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) );
1776
		}
1777
		return true;
1778
	}
1779
@@ 1792-1794 (lines=3) @@
1789
	 * @return bool
1790
	 */
1791
	public static function validate_verification_service( $value = '', $request, $param ) {
1792
		if ( ! empty( $value ) && ! ( is_string( $value ) && ( preg_match( '/^[a-z0-9_-]+$/i', $value ) || preg_match( '#^<meta name="([a-z0-9_\-.:]+)?" content="([a-z0-9_-]+)?" />$#i', $value ) ) ) ) {
1793
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string or a verification tag.', 'jetpack' ), $param ) );
1794
		}
1795
		return true;
1796
	}
1797
@@ 1934-1936 (lines=3) @@
1931
	 * @return bool
1932
	 */
1933
	public static function validate_custom_service_id( $value = '', $request, $param ) {
1934
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) {
1935
			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 ) );
1936
		}
1937
1938
		if ( ! class_exists( 'Sharing_Service' ) && ! @include( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) {
1939
			return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) );
@@ 1963-1965 (lines=3) @@
1960
	 * @return bool
1961
	 */
1962
	public static function validate_twitter_username( $value = '', $request, $param ) {
1963
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) {
1964
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) );
1965
		}
1966
		return true;
1967
	}
1968