<?php

namespace App\Entity;

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

/**
 * @ORM\Entity(repositoryClass=LocationRepository::class)
 */
class Location
{
    public const NUM_ITEMS = 10;
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    private $id;

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

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

    /**
     * @ORM\OneToMany(targetEntity=Assetregister::class, mappedBy="location")
     */
    private $assetregisters;

    public function __construct()
    {
        $this->assetregisters = 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;
    }

    public function getRemarks(): ?string
    {
        return $this->remarks;
    }

    public function setRemarks(?string $remarks): self
    {
        $this->remarks = $remarks;

        return $this;
    }

    /**
     * @return Collection|Assetregister[]
     */
    public function getAssetregisters(): Collection
    {
        return $this->assetregisters;
    }

    public function addAssetregister(Assetregister $assetregister): self
    {
        if (!$this->assetregisters->contains($assetregister)) {
            $this->assetregisters[] = $assetregister;
            $assetregister->setLocation($this);
        }

        return $this;
    }

    public function removeAssetregister(Assetregister $assetregister): self
    {
        if ($this->assetregisters->removeElement($assetregister)) {
            // set the owning side to null (unless already changed)
            if ($assetregister->getLocation() === $this) {
                $assetregister->setLocation(null);
            }
        }

        return $this;
    }
}
