<?php

namespace App\Entity;

use App\Repository\ExpenseTypeRepository;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;

/**
 * @ORM\Entity(repositoryClass=ExpenseTypeRepository::class)
 */
class ExpenseType
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    private $id;

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

    /**
     * @ORM\OneToMany(targetEntity=ExpensePurpose::class, mappedBy="expenseType")
     */
    private $expensePurposes;

    /**
     * @ORM\OneToMany(targetEntity=TourRequest::class, mappedBy="expenseType")
     */
    private $tourRequests;

    public function __construct()
    {
        $this->expensePurposes = new ArrayCollection();
        $this->tourRequests = new ArrayCollection();
    }

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getName(): ?string
    {
        return $this->name;
    }

    public function setName(string $name): self
    {
        $this->name = $name;

        return $this;
    }

    /**
     * @return Collection|ExpensePurpose[]
     */
    public function getExpensePurposes(): Collection
    {
        return $this->expensePurposes;
    }

    public function addExpensePurpose(ExpensePurpose $expensePurpose): self
    {
        if (!$this->expensePurpose->contains($expensePurpose)) {
            $this->expensePurposes[] = $expensePurpose;
            $expensePurpose->setExpenseType($this);
        }

        return $this;
    }

    public function removeExpensePurpose(ExpensePurpose $expensePurpose): self
    {
        if ($this->expensePurposes->removeElement($expensePurpose)) {
            // set the owning side to null (unless already changed)
            if ($expensePurpose->getExpenseType() === $this) {
                $expensePurpose->setExpenseType(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection|TourRequest[]
     */
    public function getTourRequests(): Collection
    {
        return $this->tourRequests;
    }

    public function addTourRequest(TourRequest $tourRequest): self
    {
        if (!$this->tourRequest->contains($tourRequest)) {
            $this->tourRequests[] = $tourRequest;
            $tourRequest->setExpenseType($this);
        }

        return $this;
    }

    public function removeTourRequest(TourRequest $tourRequest): self
    {
        if ($this->tourRequests->removeElement($tourRequest)) {
            // set the owning side to null (unless already changed)
            if ($tourRequest->getExpenseType() === $this) {
                $tourRequest->setExpenseType(null);
            }
        }

        return $this;
    }

}
