Completed
Push — master ( e8efef...889e09 )
by Denis
02:14
created

MakeViewCommand::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 16
rs 9.4285
cc 2
eloc 8
nc 2
nop 0
1
<?php
2
3
namespace Ngtfkx\Laradeck\Commands;
4
5
use Illuminate\Console\Command;
6
7
class MakeViewCommand extends Command
8
{
9
    protected $signature = 'laradeck:view {name}';
10
11
    protected $description = 'Make view';
12
13
    public function __construct()
14
    {
15
        parent::__construct();
16
    }
17
18
    public function handle()
19
    {
20
        $viewName = $this->argument('name');
21
22
        $fileNameWithPath = resource_path('views' . DIRECTORY_SEPARATOR . str_replace('.', DIRECTORY_SEPARATOR, $viewName) . '.blade.php');
23
24
        $path = dirname($fileNameWithPath);
25
26
        if (!is_dir($path)) {
27
            \File::makeDirectory($path, 0755, true);
28
        }
29
30
        \File::put($fileNameWithPath, '');
31
32
        $this->info('Success');
33
    }
34
}
35