TailwindServiceProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 24
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 6 2
A installMessage() 0 4 1
1
<?php
2
3
namespace Badworks\TailwindPreset;
4
5
use Illuminate\Support\ServiceProvider;
6
use Illuminate\Foundation\Console\PresetCommand;
7
8
class TailwindServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Bootstrap services.
12
     */
13
    public function boot()
14
    {
15
        PresetCommand::macro('tailwind', function ($command) {
16
            if ($command->confirm('This action will overwrite your existing views and assets, are you sure you want to proceed?', true)) {
17
                Tailwind::install();
18
                $this->installMessage($command);
19
            }
20
        });
21
    }
22
23
    /**
24
     * Print message after successful installation.
25
     *
26
     * @param \Illuminate\Console\Command $command
27
     */
28
    protected function installMessage($command)
29
    {
30
        $command->info('Tailwind scaffolding installed successfully.');
31
        $command->comment('Please run "npm install && npx tailwind init && npm run dev" to compile your fresh scaffolding.');
32
    }
33
}
34