<?php
/**
 * Magetop Store
 *
 * @category  Magetop Extensions
 * @package   Magetop_Quotesystem
 * @author    Magetop Developer
 * @copyright Copyright (c) Magetop (https://www.magetop.com)
 * @license   https://www.magetop.com/license.html
 */
declare(strict_types=1);

namespace Magetop\Quotesystem\Model\Config\Source;

/**
 * Websites listing column component.
 *
 * @api
 * @since 100.0.2
 */
class WebsiteOption implements \Magento\Framework\Data\OptionSourceInterface
{
    /**
     * @var array
     */
    protected $options;

    /**
     * Constructor
     *
     * @param \Magento\Store\Model\ResourceModel\Website\CollectionFactory $websiteCollectionFactory
     */
    public function __construct(
        \Magento\Store\Model\ResourceModel\Website\CollectionFactory $websiteCollectionFactory
    ) {
        $this->_websiteCollectionFactory = $websiteCollectionFactory;
    }
 
    /**
     * Retrieve websites collection of system
     *
     * @return Website Collection
     */
    public function getWebsiteCollection()
    {
        $collection = $this->_websiteCollectionFactory->create();
        return $collection;
    }

    /**
     * To Option Array
     *
     * @return Website Collection
     */
    public function toOptionArray()
    {
        $this->options = [];
        $i = 0;
        foreach ($this->getWebsiteCollection() as $website) {
            $this->options[$i] = [
                'value' => $website->getId(),
                'label' => $website->getName()
            ];
            ++$i;
        }
        return $this->options;
    }
}
