<?php

namespace App\Sms\Repository;

use App\Sms\Entity\SmsSettings;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

class SmsSettingsRepository extends ServiceEntityRepository
{
    public function __construct(ManagerRegistry $registry)
    {
        parent::__construct($registry, SmsSettings::class);
    }

    public function findByEntity(string $entityType, int $entityId): ?SmsSettings
    {
        return $this->findOneBy(['entityType' => $entityType, 'entityId' => $entityId]);
    }

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