Code Duplication    Length = 3-3 lines in 4 locations

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

@@ 1767-1769 (lines=3) @@
1764
	 * @return bool
1765
	 */
1766
	public static function validate_alphanum( $value = '', $request, $param ) {
1767
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^[a-z0-9]+$/i', $value ) ) ) {
1768
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) );
1769
		}
1770
		return true;
1771
	}
1772
@@ 1785-1787 (lines=3) @@
1782
	 * @return bool
1783
	 */
1784
	public static function validate_verification_service( $value = '', $request, $param ) {
1785
		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 ) ) ) ) {
1786
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string or a verification tag.', 'jetpack' ), $param ) );
1787
		}
1788
		return true;
1789
	}
1790
@@ 1927-1929 (lines=3) @@
1924
	 * @return bool
1925
	 */
1926
	public static function validate_custom_service_id( $value = '', $request, $param ) {
1927
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) {
1928
			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 ) );
1929
		}
1930
1931
		if ( ! class_exists( 'Sharing_Service' ) && ! @include( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) {
1932
			return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) );
@@ 1956-1958 (lines=3) @@
1953
	 * @return bool
1954
	 */
1955
	public static function validate_twitter_username( $value = '', $request, $param ) {
1956
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) {
1957
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) );
1958
		}
1959
		return true;
1960
	}
1961