<?php

declare(strict_types=1);

namespace App\Module\Commercial\Infrastructure\Doctrine;

use App\Module\Commercial\Domain\Entity\ClientAddress;
use App\Module\Commercial\Domain\Repository\ClientAddressRepositoryInterface;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

/**
 * @extends ServiceEntityRepository<ClientAddress>
 */
class DoctrineClientAddressRepository extends ServiceEntityRepository implements ClientAddressRepositoryInterface
{
    public function __construct(ManagerRegistry $registry)
    {
        parent::__construct($registry, ClientAddress::class);
    }

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

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