<?php

declare(strict_types=1);

namespace Apexl\Vault\Enums;

use Apexl\Vault\Interfaces\ConditionType;
use Apexl\Vault\Interfaces\QueryBuilderInterface;
use Henzeb\Enumhancer\Concerns\Getters;

enum HavingType implements ConditionType
{
    use Getters;

    case AND;
    case OR;

    public function toCallable(QueryBuilderInterface $query): callable
    {
        return match ($this) {
            self::AND => $query->having(...),
            self::OR => $query->orHaving(...),
        };
    }
}
