<?php

declare(strict_types=1);

namespace App\Repository;

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

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

    /**
     * @return list<MailFolder>
     */
    public function findAllOrderedByPath(): array
    {
        return $this->createQueryBuilder('f')
            ->orderBy('f.path', 'ASC')
            ->getQuery()
            ->getResult()
        ;
    }

    public function findByPath(string $path): ?MailFolder
    {
        return $this->findOneBy(['path' => $path]);
    }
}
