<?php

namespace App\Repository;

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

/**
 * @extends ServiceEntityRepository<StripeWebhookSecret>
 *
 * @codeCoverageIgnore
 */
class StripeWebhookSecretRepository extends ServiceEntityRepository
{
    public function __construct(ManagerRegistry $registry)
    {
        parent::__construct($registry, StripeWebhookSecret::class);
    }

    public function findByType(string $type): ?StripeWebhookSecret
    {
        return $this->findOneBy(['type' => $type]);
    }

    public function getSecret(string $type): ?string
    {
        $entity = $this->findByType($type);

        return $entity?->getSecret();
    }
}
