<?php

namespace App\Entity;

use App\Repository\PadreRepository;
use DateTimeImmutable;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\Table;

/**
 * @ORM\Entity(repositoryClass=PadreRepository::class)
 * @Table(name="padres")
 */
class Padre
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     * @var int
     */
    private $id;

    /**
     * @ORM\Column(type="string", length=100)
     * @var string
     */
    private $firstname;

    /**
     * @ORM\Column(type="string", length=100)
     * @var string
     */
    private $lastname;

    /**
     * @ORM\OneToMany(targetEntity=Baptism::class, mappedBy="padre")
     * @var ArrayCollection<int,Baptism>
     */
    private $baptisms;

    /**
     * @ORM\Column(type="datetime_immutable")
     * @var DateTimeImmutable
     */
    private $created_at;

    /**
     * @ORM\Column(type="datetime_immutable", nullable=true)
     * @var DateTimeImmutable
     */
    private $updated_at;

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

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

    public function getFirstname(): ?string
    {
        return $this->firstname;
    }

    public function setFirstname(string $firstname): self
    {
        $this->firstname = $firstname;

        return $this;
    }

    public function getLastname(): ?string
    {
        return $this->lastname;
    }

    public function setLastname(string $lastname): self
    {
        $this->lastname = $lastname;

        return $this;
    }

    /**
     * @return ArrayCollection<int,Baptism>
     */
    public function getBaptisms(): Collection
    {
        return $this->baptisms;
    }

    public function addBaptism(Baptism $baptism): self
    {
        if (!$this->baptisms->contains($baptism)) {
            $this->baptisms[] = $baptism;
            $baptism->setPadre($this);
        }

        return $this;
    }

    public function removeBaptism(Baptism $baptism): self
    {
        if ($this->baptisms->removeElement($baptism)) {
            // set the owning side to null (unless already changed)
            if ($baptism->getPadre() === $this) {
                $baptism->setPadre(null);
            }
        }

        return $this;
    }

    public function getCreatedAt(): ?\DateTimeImmutable
    {
        return $this->created_at;
    }

    public function setCreatedAt(\DateTimeImmutable $created_at): self
    {
        $this->created_at = $created_at;

        return $this;
    }

    public function getUpdatedAt(): ?\DateTimeImmutable
    {
        return $this->updated_at;
    }

    public function setUpdatedAt(?\DateTimeImmutable $updated_at): self
    {
        if ($updated_at != null)
            $this->updated_at = $updated_at;

        return $this;
    }
}
