Code Duplication    Length = 3-3 lines in 4 locations

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

@@ 1751-1753 (lines=3) @@
1748
	 * @return bool
1749
	 */
1750
	public static function validate_alphanum( $value = '', $request, $param ) {
1751
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^[a-z0-9]+$/i', $value ) ) ) {
1752
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) );
1753
		}
1754
		return true;
1755
	}
1756
@@ 1769-1771 (lines=3) @@
1766
	 * @return bool
1767
	 */
1768
	public static function validate_verification_service( $value = '', $request, $param ) {
1769
		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 ) ) ) ) {
1770
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string or a verification tag.', 'jetpack' ), $param ) );
1771
		}
1772
		return true;
1773
	}
1774
@@ 1911-1913 (lines=3) @@
1908
	 * @return bool
1909
	 */
1910
	public static function validate_custom_service_id( $value = '', $request, $param ) {
1911
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) {
1912
			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 ) );
1913
		}
1914
1915
		if ( ! class_exists( 'Sharing_Service' ) && ! @include( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) {
1916
			return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) );
@@ 1940-1942 (lines=3) @@
1937
	 * @return bool
1938
	 */
1939
	public static function validate_twitter_username( $value = '', $request, $param ) {
1940
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) {
1941
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) );
1942
		}
1943
		return true;
1944
	}
1945