<?php

namespace Magetop\Agency\Model\Plugin;

use Magento\Quote\Model\Quote\TotalsCollector as Collector;

class TotalsCollector
{
    /**
     * @var \Magetop\Agency\Helper\Data
     */
    private $_helper;

    /**
     * Initialize dependencies.
     *
     * @param \Magetop\Agency\Helper\Data $helper
     */
    public function __construct(
        \Magetop\Agency\Helper\Data $helper
    ) {
        $this->_helper = $helper;
    }

    public function aroundCollect(
        Collector $subject,
        \Closure $proceed,
        \Magento\Quote\Model\Quote $quote
    ) {
        $this->_helper->collectTotals($quote);
        $result = $proceed($quote);
        return $result;
    }
}
