<?php

namespace Lc\ShopBundle\Model;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Lc\ShopBundle\Context\FilterMerchantInterface;
use Lc\ShopBundle\Context\ReductionCatalogInterface;
use Lc\ShopBundle\Context\ReductionInterface;
use Lc\ShopBundle\Context\ReductionPropertyInterface;
use Lc\ShopBundle\Context\StatusInterface;
use phpDocumentor\Reflection\Types\Integer;

/**
 * @ORM\MappedSuperclass()
 */
abstract class ReductionCatalog extends AbstractEntity implements ReductionCatalogInterface, ReductionPropertyInterface, FilterMerchantInterface, StatusInterface
{
        use StatusTrait;
        use ReductionTrait;
        use ReductionPropertyTrait{
                ReductionPropertyTrait::__construct as private __reductionPropertyConstruct;
        }

        /**
         * @ORM\Column(type="string", length=255)
         */
        protected $title;

        /**
         * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface")
         * @ORM\JoinColumn(nullable=false)
         */
        protected $merchant;

        /**
         * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\ProductFamilyInterface")
         */
        protected $productFamilies;

        /**
         * @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\ProductFamilyInterface")
         */
        protected $productFamily;

        /**
         * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\ProductCategoryInterface")
         */
        protected $productCategories;


        public function __construct()
        {
                $this->__reductionPropertyConstruct();
                $this->productFamilies = new ArrayCollection();
                $this->productCategories = new ArrayCollection();
        }

        public function getTitle(): ?string
        {
                return $this->title;
        }

        public function setTitle(string $title): self
        {
                $this->title = $title;

                return $this;
        }


        public function getMerchant(): ?Merchant
        {
                return $this->merchant;
        }

        public function setMerchant(?Merchant $merchant): self
        {
                $this->merchant = $merchant;

                return $this;
        }


        /**
         * @return Collection|ProductFamily[]
         */
        public function getProductFamilies(): Collection
        {
                return $this->productFamilies;
        }

        public function addProductFamily(ProductFamily $productFamily): self
        {
                if (!$this->productFamilies->contains($productFamily)) {
                        $this->productFamilies[] = $productFamily;
                }

                return $this;
        }

        public function removeProductFamily(ProductFamily $productFamily): self
        {
                if ($this->productFamilies->contains($productFamily)) {
                        $this->productFamilies->removeElement($productFamily);
                }

                return $this;
        }


        public function getProductFamily(): ?ProductFamily
        {
                return $this->productFamily;
        }

        public function setProductFamily(?ProductFamily $productFamily): self
        {
                $this->productFamily = $productFamily;

                return $this;
        }


        /**
         * @return Collection|ProductCategory[]
         */
        public function getProductCategories(): Collection
        {
                return $this->productCategories;
        }

        public function addProductCategory(ProductCategory $productCategory): self
        {
                if (!$this->productCategories->contains($productCategory)) {
                        $this->productCategories[] = $productCategory;
                }

                return $this;
        }

        public function removeProductCategory(ProductCategory $productCategory): self
        {
                if ($this->productCategories->contains($productCategory)) {
                        $this->productCategories->removeElement($productCategory);
                }

                return $this;
        }

}