Code Duplication    Length = 3-3 lines in 4 locations

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

@@ 1790-1792 (lines=3) @@
1787
	 * @return bool
1788
	 */
1789
	public static function validate_alphanum( $value = '', $request, $param ) {
1790
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^[a-z0-9]+$/i', $value ) ) ) {
1791
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) );
1792
		}
1793
		return true;
1794
	}
1795
@@ 1808-1810 (lines=3) @@
1805
	 * @return bool
1806
	 */
1807
	public static function validate_verification_service( $value = '', $request, $param ) {
1808
		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 ) ) ) ) {
1809
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string or a verification tag.', 'jetpack' ), $param ) );
1810
		}
1811
		return true;
1812
	}
1813
@@ 1950-1952 (lines=3) @@
1947
	 * @return bool
1948
	 */
1949
	public static function validate_custom_service_id( $value = '', $request, $param ) {
1950
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) {
1951
			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 ) );
1952
		}
1953
1954
		if ( ! class_exists( 'Sharing_Service' ) && ! include_once( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) {
1955
			return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) );
@@ 1979-1981 (lines=3) @@
1976
	 * @return bool
1977
	 */
1978
	public static function validate_twitter_username( $value = '', $request, $param ) {
1979
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) {
1980
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) );
1981
		}
1982
		return true;
1983
	}
1984