<?php

namespace BinaryBuilds\LaritorClient\Commands;

use Illuminate\Console\GeneratorCommand;
use Illuminate\Support\Str;

class HealthCheckMakeCommand extends GeneratorCommand
{
    /**
     * The console command name.
     *
     * @var string
     */
    protected $name = 'make:laritor-custom-hc';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Create a custom health check for laritor';

    /**
     * The type of class being generated.
     *
     * @var string
     */
    protected $type = 'HealthCheck';

    /**
     * Get the stub file for the generator.
     *
     * @return string
     */
    protected function getStub()
    {
       return __DIR__.'/../../stubs/LaritorHealthCheck.stub';
    }

    /**
     * Get the default namespace for the class.
     *
     * @param  string  $rootNamespace
     * @return string
     */
    protected function getDefaultNamespace($rootNamespace)
    {
        return $rootNamespace.'\Laritor';
    }

    /**
     * @param string $name
     * @return array|string|string[]
     * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
     */
    protected function buildClass($name)
    {
        $stub = parent::buildClass($name);

        $pieces = explode('\\', $name);

        return str_replace(['{{ name }}'], Str::headline($pieces[count($pieces) - 1]), $stub);
    }
}
