<?php

declare(strict_types=1);

namespace App\Module\Catalog\Infrastructure\Doctrine;

use App\Module\Catalog\Domain\Entity\CategoryType;
use App\Module\Catalog\Domain\Repository\CategoryTypeRepositoryInterface;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

/**
 * @extends ServiceEntityRepository<CategoryType>
 */
class DoctrineCategoryTypeRepository extends ServiceEntityRepository implements CategoryTypeRepositoryInterface
{
    public function __construct(ManagerRegistry $registry)
    {
        parent::__construct($registry, CategoryType::class);
    }

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

    /**
     * @return list<CategoryType>
     */
    public function findAllOrderedByLabel(): array
    {
        return $this->findBy([], ['label' => 'ASC']);
    }
}
