Completed
Pull Request — master (#5)
by
unknown
05:20 queued 01:32
created

ViewModelMakeCommand   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 29
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 8 3
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 getStub()
26
    {
27
        return __DIR__.'/../../stubs/DummyViewModel.stub';
28
    }
29
30
    protected function getOptions(): array
31
    {
32
        return [
33
            ['force', null, InputOption::VALUE_NONE, 'Create the class even if the view-model already exists'],
34
        ];
35
    }
36
}
37