<?php

namespace ModulesGarden\Servers\ZimbraEmail\App\Services\ConfigurableOptions\Strategy\Types;


use ModulesGarden\Servers\ZimbraEmail\App\Services\ConfigurableOptions\Models\Option;
use ModulesGarden\Servers\ZimbraEmail\App\Traits\LangHandler;

/**
 *
 * Created by PhpStorm.
 * User: Tomasz Bielecki ( tomasz.bi@modulesgarden.com )
 * Date: 30.09.19
 * Time: 12:21
 * Class AbstractOptions
 */
abstract class AbstractOptions
{
    use LangHandler;

    /**
     * @var array
     */
    protected $options = [];

    /**
     * @var
     */
    protected $productId;

    /**
     * AbstractOptions constructor.
     */
    public function __construct($productId = null)
    {
        if($productId)
        {
            $this->setProductId($productId);
        }

        /**
         * load configurable options
         */
        $this->initContent();
    }

    /**
     * @return mixed
     */
    public function getProductId()
    {
        return $this->productId;
    }

    /**
     * @param $productId
     * @return $this
     */
    public function setProductId($productId)
    {
        $this->productId = $productId;
        return $this;
    }



    /**
     * @param Option $option
     * @return $this
     */
    public function addOption(Option $option)
    {
        $this->options[$option->getKey()] = $option;
        return $this;
    }

    /**
     * @return array
     */
    public function getOptions()
    {
        return $this->options;
    }

    /**
     * load all options
     *
     * @return mixed
     */
    public abstract function initContent();

}