<?php

namespace Lucent\Query\Operator;


final class OperatorRegistry
{
    /**
     * @return list<Operator>
     */
    public function all(): array
    {
        return [
            new Equals(),
            new NotEquals(),
            new EqualsNumber(),
            new NotEqualsNumber(),
            new EqualsTrue(),
            new EqualsFalse(),
            new NotEqualsFalse(),
            new NotEqualsTrue(),
            new Regex(),
            new In(),
            new NotIn(),
            new InNum(),
            new NotInNum(),
            new GreaterThan(),
            new GreaterThanEquals(),
            new LessThan(),
            new LessThanEquals(),
            new IsNull(),
            new NotNull(),
            new Exists(),
            new NotExists(),

        ];
    }

    public function matchByName(string $name): Operator
    {
        $operator = collect($this->all())->where('name', $name)->first();
        if (empty($operator)) {
            return new Equals();
        }
        return $operator;
    }


}
