<?php
/**
 * Plumrocket Inc.
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the End-user License Agreement
 * that is available through the world-wide-web at this URL:
 * http://wiki.plumrocket.net/wiki/EULA
 * If you are unable to obtain it through the world-wide-web, please
 * send an email to support@plumrocket.com so we can send you a copy immediately.
 *
 * @package     Plumrocket_ProductFilter
 * @copyright   Copyright (c) 2020 Plumrocket Inc. (http://www.plumrocket.com)
 * @license     http://wiki.plumrocket.net/wiki/EULA  End-user License Agreement
 */

declare(strict_types=1);

namespace Plumrocket\ProductFilter\Model\CatalogSearch\Model\ResourceModel\Fulltext\Collection;

use Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection;

/**
 * Temporary fix for
 * @link https://github.com/magento/magento2/issues/28919
 * TODO: remove after left support magento version with bug
 *
 * @since 3.2.12
 */
class CurrentLoading
{
    /**
     * @var \Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection|null
     */
    private $collection;

    /**
     * @var array
     */
    private $priceData = [];

    /**
     * @return \Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection|null
     */
    public function get()
    {
        return $this->collection;
    }

    /**
     * @param \Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection $collection
     * @return $this
     */
    public function set(Collection $collection): CurrentLoading
    {
        $this->collection = $collection;
        return $this;
    }

    /**
     * @return $this
     */
    public function reset(): CurrentLoading
    {
        $this->collection = null;
        $this->priceData = [];
        return $this;
    }

    /**
     * @return array
     */
    public function getPriceData(): array
    {
        return $this->priceData;
    }

    /**
     * @param array $priceData
     * @return $this
     */
    public function setPriceData(array $priceData): CurrentLoading
    {
        $this->priceData = $priceData;
        return $this;
    }
}
