Code Duplication    Length = 3-3 lines in 4 locations

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

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