Code Duplication    Length = 3-3 lines in 3 locations

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

@@ 1696-1698 (lines=3) @@
1693
	 * @return bool
1694
	 */
1695
	public static function validate_alphanum( $value = '', $request, $param ) {
1696
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/[a-z0-9]+/i', $value ) ) ) {
1697
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) );
1698
		}
1699
		return true;
1700
	}
1701
@@ 1835-1837 (lines=3) @@
1832
	 * @return bool
1833
	 */
1834
	public static function validate_custom_service_id( $value = '', $request, $param ) {
1835
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) {
1836
			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 ) );
1837
		}
1838
1839
		if ( ! class_exists( 'Sharing_Service' ) && ! @include( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) {
1840
			return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) );
@@ 1864-1866 (lines=3) @@
1861
	 * @return bool
1862
	 */
1863
	public static function validate_twitter_username( $value = '', $request, $param ) {
1864
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) {
1865
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) );
1866
		}
1867
		return true;
1868
	}
1869