<?php

declare(strict_types=1);

namespace App\Module\Commercial\Infrastructure\Doctrine;

use App\Module\Commercial\Domain\Entity\SupplierContact;
use App\Module\Commercial\Domain\Repository\SupplierContactRepositoryInterface;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

/**
 * @extends ServiceEntityRepository<SupplierContact>
 */
class DoctrineSupplierContactRepository extends ServiceEntityRepository implements SupplierContactRepositoryInterface
{
    public function __construct(ManagerRegistry $registry)
    {
        parent::__construct($registry, SupplierContact::class);
    }

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

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