<?php

declare(strict_types=1);

namespace App\Module\Commercial\Infrastructure\Doctrine;

use App\Module\Commercial\Domain\Entity\ClientContact;
use App\Module\Commercial\Domain\Repository\ClientContactRepositoryInterface;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

/**
 * @extends ServiceEntityRepository<ClientContact>
 */
class DoctrineClientContactRepository extends ServiceEntityRepository implements ClientContactRepositoryInterface
{
    public function __construct(ManagerRegistry $registry)
    {
        parent::__construct($registry, ClientContact::class);
    }

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

    public function save(ClientContact $contact): void
    {
        $this->getEntityManager()->persist($contact);
        $this->getEntityManager()->flush();
    }
}
