<?php 
namespace Sargilla\Flatlab4\Console;

use Illuminate\Console\Command;
use Sargilla\Flatlab4\Facades\Flatlab4;
use Illuminate\Filesystem\Filesystem;

/**
 * Class Publish FlatLab.
 */
class PublishFlatlab4 extends Command
{
    use Installable;
    /**
     * The filesystem instance.
     *
     * @var \Illuminate\Filesystem\Filesystem
     */
    protected $files;

    /**
     * The name and signature of the console command.
     */
    protected $signature = 'flatlab4:publish {--f|force : Force overwrite of files}';    

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Publicar Archivos de Flatlab4';

    /**
     * Force overwrite of files.
     *
     * @var bool
     */
    protected $force = false;

    /**
     * Create a new command instance.
     *
     * @param \Illuminate\Filesystem\Filesystem $files
     *
     */
    public function __construct(Filesystem $files)
    {
        parent::__construct();
        $this->files = $files;
    }

    /**
     * Execute the console command.
     */
    public function handle()
    {
        $this->processOptions();
        $this->publishLanguages();
        $this->publishConfig();
        $this->publishViews();
        $this->publishGravatar();
    }

    /**
     * Install FlatLab Language assets.
     */
    private function publishLanguages()
    {
        $this->install(Flatlab4::languages());
    }

    /**
     * Publish FlatLab package config.
     */
    private function publishConfig()
    {
        $this->install(Flatlab4::config());
    }

    /**
     * Install FlatLab views.
     */
    private function publishViews()
    {
        $this->install(Flatlab4::views());
    }

    /**
     * Install gravatar config file.
     */
    private function publishGravatar()
    {
       $this->install(Flatlab4::gravatar());
    }

    /**
     * Process options before running command.
     */
    private function processOptions()
    {
        $this->force = $this->option('force');
    }

}
