InstallExamplesCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
eloc 12
c 0
b 0
f 0
dl 0
loc 42
ccs 0
cts 11
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A handle() 0 11 1
1
<?php
2
3
namespace MallardDuck\DynamicEcho\Commands;
4
5
use Illuminate\Console\Command;
6
use Illuminate\Filesystem\Filesystem;
7
8
class InstallExamplesCommand extends Command
9
{
10
    /**
11
     * The name and signature of the console command.
12
     *
13
     * @var string
14
     */
15
    protected $signature = 'dynamic-echo:examples';
16
17
    /**
18
     * The console command description.
19
     *
20
     * @var string
21
     */
22
    protected $description = 'Publish the example event classes for an easy start.';
23
24
    /**
25
     * Create a new command instance.
26
     *
27
     * @return void
28
     */
29
    public function __construct()
30
    {
31
        parent::__construct();
32
    }
33
34
    /**
35
     * Execute the console command.
36
     *
37
     * @return int
38
     */
39
    public function handle(): int
40
    {
41
        $this->info("Starting installer for example events.");
42
        (new Filesystem())->ensureDirectoryExists(app_path('Events'));
43
44
        $this->info("Installing ConsoleLogEvent.");
45
        copy(__DIR__ . '/../../../examples/app/Events/ConsoleLogEvent.php', app_path('Events/ConsoleLogEvent.php'));
46
        $this->info("Installing ToastEvent.");
47
        copy(__DIR__ . '/../../../examples/app/Events/ToastEvent.php', app_path('Events/ToastEvent.php'));
48
        $this->info("Examples installed.");
49
        return 0;
50
    }
51
}
52