<?php

namespace App\Repository\TimeLogType;

use App\Entity\TimeLogType;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Symfony\Bridge\Doctrine\RegistryInterface;

final class DoctrineTimeLogTypeRepository extends ServiceEntityRepository implements TimeLogTypeRepositoryInterface
{
    public function __construct(RegistryInterface $registry)
    {
        parent::__construct($registry, TimeLogType::class);
    }

    public function findById(int $id): ?TimeLogType
    {
        return $this->findOneBy(['id' => $id]);
    }

    /**
     * @param TimeLogType $timeLogType
     *
     * @throws \Doctrine\ORM\ORMException
     * @throws \Doctrine\ORM\OptimisticLockException
     */
    public function save(TimeLogType $timeLogType): void
    {
        $this->_em->persist($timeLogType);
        $this->_em->flush();
    }

    /**
     * @param TimeLogType $timeLogType
     *
     * @throws \Doctrine\ORM\ORMException
     * @throws \Doctrine\ORM\OptimisticLockException
     */
    public function delete(TimeLogType $timeLogType): void
    {
        $this->_em->remove($timeLogType);
        $this->_em->flush();
    }
}
