<?php

declare(strict_types=1);

namespace Builder\Core\Foundation\Commands;

use Illuminate\Support\Str;

final class MakeSettingsCommand extends MakeBuilderFileCommand
{
    protected $signature = 'builder:make:settings
        {name : The class name of the settings page (e.g. SkeletonSettings)}
        {--force : Overwrite the settings class if it already exists}';

    protected $description = 'Create a new Builder settings class';

    protected function stubName(): string
    {
        return 'settings';
    }

    protected function outputSubdirectory(): string
    {
        return 'Settings';
    }

    protected function packageStubsPath(): string
    {
        return __DIR__.'/../../../stubs';
    }

    /** @return array<string, string> */
    protected function buildReplacements(string $className): array
    {
        $base = Str::replaceLast('Settings', '', $className);

        return [
            'namespace' => 'App\\Builder\\Settings',
            'class' => $className,
            'group' => Str::snake($base),
            'label' => Str::headline($base),
        ];
    }
}
