I had the same problem in a client project @ jivith.com
But I decided ...
Using the minicart / cart function replaces the total number of products in the basket - not their quantity.
$_cartQty = count( WC()->cart->get_cart() ); **or** use sizeof (WC()->cart->get_cart());
I get the total number of unique final products in the basket, and not an element of their quantity ...
My demo code:
<span class="cart-items"><?php echo ($minicart_type == 'minicart-inline') ? '<span class="mobile-hide">' . sprintf( _n( '%d item', '%d items', $_cartQty, 'porto' ), $_cartQty ) . '</span><span class="mobile-show">' . $_cartQty . '</span>' : (($_cartQty > 0) ? $_cartQty : '0'); ?></span>
source share