LarrockRenamePublicDirectoryCommand::handle()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 1 Features 0
Metric Value
cc 2
eloc 9
c 3
b 1
f 0
nc 2
nop 0
dl 0
loc 12
rs 9.9666
1
<?php
2
3
namespace Larrock\Core\Commands;
4
5
use Illuminate\Console\Command;
6
7
class LarrockRenamePublicDirectoryCommand extends Command
8
{
9
    /**
10
     * The name and signature of the console command.
11
     *
12
     * @var string
13
     */
14
    protected $signature = 'larrock:renamePublicDirectory';
15
16
    /**
17
     * The console command description.
18
     *
19
     * @var string
20
     */
21
    protected $description = 'Rename public directory to "public_html"';
22
23
    /**
24
     * Execute the console command.
25
     *
26
     * @return mixed
27
     */
28
    public function handle()
29
    {
30
        $this->line('=== Rename public directory to "public_html" ===');
31
32
        if (! \File::exists(base_path('public_html/index.php'))) {
33
            \File::copyDirectory(base_path('public'), base_path('public_html'));
34
            \File::deleteDirectory(base_path('public'));
35
            $dir = str_replace('/Commands', '', __DIR__);
36
            \File::copy($dir.'/../configVendor/larrock-index-public_html_php', base_path('public_html/index.php'));
37
            $this->info('Directory and index.php successfully updated');
38
        } else {
39
            $this->info('The command is not required, the directory has already changed.');
40
        }
41
    }
42
}
43