Completed
Pull Request — master (#5)
by
unknown
02:18
created

ViewModelMakeCommand   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 1
dl 0
loc 34
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 8 3
A getDefaultNamespace() 0 4 1
A getStub() 0 4 1
A getOptions() 0 6 1
1
<?php
2
3
namespace Spatie\ViewModels\Console;
4
5
use Illuminate\Console\GeneratorCommand;
6
use Symfony\Component\Console\Input\InputOption;
7
8
class ViewModelMakeCommand extends GeneratorCommand
9
{
10
    protected $name = 'make:view-model';
11
12
    protected $description = 'Create a new ViewModel class';
13
14
    protected $type = 'ViewModel';
15
16
    public function handle()
17
    {
18
        if (parent::handle() === false) {
19
            if (! $this->option('force')) {
20
                return;
21
            }
22
        }
23
    }
24
25
    protected function getDefaultNamespace($rootNamespace)
26
    {
27
        return $rootNamespace.'\ViewModels';
28
    }
29
30
    protected function getStub()
31
    {
32
        return __DIR__.'/../../stubs/DummyViewModel.stub';
33
    }
34
35
    protected function getOptions(): array
36
    {
37
        return [
38
            ['force', null, InputOption::VALUE_NONE, 'Create the class even if the view-model already exists'],
39
        ];
40
    }
41
}
42