<?php

declare(strict_types=1);

namespace Builder\Core\Support;

final class Module
{
    public static function has(string $key): bool
    {
        return app()->bound("builder.{$key}");
    }

    /**
     * Return $fields when the module is loaded, otherwise an empty array.
     *
     * @param  list<mixed>  $fields
     * @return list<mixed>
     */
    public static function when(string $key, array $fields): array
    {
        return self::has($key) ? $fields : [];
    }
}
