<?php

declare(strict_types=1);

namespace App\Module\Commercial\Infrastructure\Doctrine;

use App\Module\Commercial\Domain\Entity\SupplierRib;
use App\Module\Commercial\Domain\Repository\SupplierRibRepositoryInterface;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

/**
 * @extends ServiceEntityRepository<SupplierRib>
 */
class DoctrineSupplierRibRepository extends ServiceEntityRepository implements SupplierRibRepositoryInterface
{
    public function __construct(ManagerRegistry $registry)
    {
        parent::__construct($registry, SupplierRib::class);
    }

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

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