private function validateCartLine(CartLineInterface $cartLine)
    {
        $cart = $cartLine->getCart();
        $purchasable = $cartLine->getPurchasable();
        $realStockAvailable = $this
            ->purchasableStockValidator
            ->isStockAvailable(
                $purchasable,
                $cartLine->getQuantity(),
                $this->useStock
            );

        if (
            false === $realStockAvailable ||
            $realStockAvailable === 0
        ) {
            $this->cartManager->silentRemoveLine(
                $cart,
                $cartLine
            );

            /**
             * An inconsistent cart event is dispatched.
             */
            $this
                ->cartEventDispatcher
                ->dispatchCartInconsistentEvent(
                    $cart,
                    $cartLine
                );

            return $cartLine;
        }

        if (is_int($realStockAvailable)) {
            $cartLine->setQuantity($realStockAvailable);
        }

        return $cartLine;
    }
private function validateCartLine(CartLineInterface $cartLine)
    {
        $cart = $cartLine->getCart();
        $purchasable = $cartLine->getPurchasable();
        $realStockAvailable = $this
            ->purchasableStockValidator
            ->isStockAvailable(
                $purchasable,
                $cartLine->getQuantity(),
                $this->useStock
            );

        if (
            false === $realStockAvailable ||
            $realStockAvailable === 0
        ) {
            $this->cartManager->silentRemoveLine(
                $cart,
                $cartLine
            );

            /**
             * An inconsistent cart event is dispatched.
             */
            $this
                ->cartEventDispatcher
                ->dispatchCartInconsistentEvent(
                    $cart,
                    $cartLine
                );

            return $cartLine;
        }

        if (is_int($realStockAvailable)) {
            $cartLine->setQuantity($realStockAvailable);
        }

        return $cartLine;
    }
private function validateCartLine ( CartLineInterface $ cartLine ) { $ cart = $ cartLine -> getCart ( ) ; $ purchasable = $ cartLine -> getPurchasable ( ) ; $ realStockAvailable = $ this -> purchasableStockValidator -> isStockAvailable ( $ purchasable , $ cartLine -> getQuantity ( ) , $ this -> useStock ) ; if ( false === $ realStockAvailable || $ realStockAvailable === 0 ) { $ this -> cartManager -> silentRemoveLine ( $ cart , $ cartLine ) ; /**
             * An inconsistent cart event is dispatched.
             */ $ this -> cartEventDispatcher -> dispatchCartInconsistentEvent ( $ cart , $ cartLine ) ; return $ cartLine ; } if ( is_int ( $ realStockAvailable ) ) { $ cartLine -> setQuantity ( $ realStockAvailable ) ; } return $ cartLine ; }
Check CartLine integrity.

When a purchasable is not enabled or its quantity is <=0,
the line is discarded and a ElcodiCartEvents::CART_INCONSISTENT
event is fired.

A further check on stock availability is performed so that when
$quantity is greater that the available units, $quantity for this
CartLine is set to Purchasable::$stock number

@param CartLineInterface $cartLine Cart line

@return CartLineInterface CartLine
Check CartLine integrity .