<?php

namespace KupShop\WarehouseBundle\Entity;

class StoreItem
{
    /**
     * @var \Product
     */
    protected $product;

    /**
     * @var int
     */
    protected $id_product;
    /**
     * @var int|null
     */
    protected $id_variation;
    /**
     * @var bool
     */
    protected $over_supply = false;

    /**
     * @var int|null
     */
    protected $id_product_batch;

    public function __construct($itemRow)
    {
        $this->createFromItemRow($itemRow);
    }

    public function createFromItemRow($itemRow)
    {
        foreach ($itemRow as $key => $value) {
            if (property_exists($this, $key)) {
                $this->{$key} = $value;
            }
        }
    }

    public function getIdProduct(): int
    {
        return $this->id_product;
    }

    public function getIdVariation(): ?int
    {
        return $this->id_variation;
    }

    public function isOverSupply(): bool
    {
        return $this->over_supply === 'Y' || $this->over_supply === true;
    }

    public function getIdProductsBatch(): ?int
    {
        return $this->id_product_batch;
    }

    public function getProduct(): \Product
    {
        return $this->product;
    }
}
