Passed
Branch master (d88b3b)
by Prateek
03:56
created

Initialize   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 30
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 11 3
1
<?php
2
namespace Prateekkarki\Laragen\Commands;
3
4
use Illuminate\Console\Command;
5
6
class Initialize extends Command
7
{
8
    /**
9
     * The name and signature of the console command.
10
     *
11
     * @var string
12
     */
13
    protected $signature = 'laragen:init';
14
    /**
15
     * The console command description.
16
     *
17
     * @var string
18
     */
19
    protected $description = 'Initializing laragen';
20
    /**
21
     * Execute the console command.
22
     *
23
     * @return mixed
24
     */
25
    public function handle()
26
    {
27
        copy(__DIR__ . '/../../src/resources/stubs/RouteServiceProvider.stub', app_path('Providers/LaragenRouteServiceProvider.php'));
28
        if (!is_dir('routes/backend')) {
29
            @mkdir(base_path('routes/backend'), 0777, true);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition for mkdir(). This can introduce security issues, and is generally not recommended. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unhandled  annotation

29
            /** @scrutinizer ignore-unhandled */ @mkdir(base_path('routes/backend'), 0777, true);

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
30
            copy(__DIR__ . '/../../src/resources/stubs/Route.stub', base_path('routes/backend/web.php'));
31
            copy(__DIR__ . '/../../src/resources/stubs/Route.stub', base_path('routes/backend/auth.php'));
32
        }
33
        if (!is_dir('routes/frontend')) {
34
            @mkdir(base_path('routes/frontend'), 0777, true);
35
            copy(__DIR__ . '/../../src/resources/stubs/Route.stub', base_path('routes/frontend/web.php'));
36
        }
37
    }
38
}
39