Code Duplication    Length = 3-3 lines in 3 locations

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

@@ 1568-1570 (lines=3) @@
1565
	 * @return bool
1566
	 */
1567
	public static function validate_alphanum( $value = '', $request, $param ) {
1568
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/[a-z0-9]+/i', $value ) ) ) {
1569
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) );
1570
		}
1571
		return true;
1572
	}
1573
@@ 1707-1709 (lines=3) @@
1704
	 * @return bool
1705
	 */
1706
	public static function validate_custom_service_id( $value = '', $request, $param ) {
1707
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) {
1708
			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 ) );
1709
		}
1710
1711
		if ( ! class_exists( 'Sharing_Service' ) && ! @include( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) {
1712
			return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) );
@@ 1736-1738 (lines=3) @@
1733
	 * @return bool
1734
	 */
1735
	public static function validate_twitter_username( $value = '', $request, $param ) {
1736
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) {
1737
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) );
1738
		}
1739
		return true;
1740
	}
1741