<?php

declare(strict_types=1);

namespace App\Module\Commercial\Infrastructure\Doctrine;

use App\Module\Commercial\Domain\Entity\SupplierAddress;
use App\Module\Commercial\Domain\Repository\SupplierAddressRepositoryInterface;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

/**
 * @extends ServiceEntityRepository<SupplierAddress>
 */
class DoctrineSupplierAddressRepository extends ServiceEntityRepository implements SupplierAddressRepositoryInterface
{
    public function __construct(ManagerRegistry $registry)
    {
        parent::__construct($registry, SupplierAddress::class);
    }

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

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