Passed
Push — master ( 2fd2da...07f956 )
by Arthur
35:40 queued 30:04
created

FactoryMakeCommand::stubOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Foundation\Generator\Commands;
4
5
use Foundation\Generator\Abstracts\AbstractGeneratorCommand;
6
use Symfony\Component\Console\Input\InputOption;
7
8
class FactoryMakeCommand extends AbstractGeneratorCommand
9
{
10
    /**
11
     * The console command name.
12
     *
13
     * @var string
14
     */
15
    protected $name = 'larapi:make:factory';
16
17
    /**
18
     * The console command description.
19
     *
20
     * @var string
21
     */
22
    protected $description = 'Create a new model factory for the specified module.';
23
24
    /**
25
     * The name of the generated resource.
26
     *
27
     * @var string
28
     */
29
    protected $generatorName = 'factory';
30
31
    /**
32
     * The stub name.
33
     *
34
     * @var string
35
     */
36
    protected $stub = 'factory.stub';
37
38
    /**
39
     * The file path.
40
     *
41
     * @var string
42
     */
43
    protected $filePath = '/Database/factories';
44
45 1
    protected function getModelName(): string
46
    {
47
        return once(function () {
48 1
            return $this->option('model') ?? $this->anticipate('For what model would you like to generate a factory?', [$this->getModuleName()], $this->getModuleName());
49 1
        });
50
    }
51
52 1
    protected function getClassName() :string
53
    {
54 1
        return $this->getModelName().'Factory';
55
    }
56
57 1
    protected function stubOptions(): array
58
    {
59
        return [
60 1
            'CLASS' => $this->getClassName(),
61 1
            'MODEL' => $this->getModelName(),
62 1
            'MODEL_NAMESPACE' => $this->getModule()->getNamespace().'\\'.'Entities'.'\\'.$this->getModelName(),
63
        ];
64
    }
65
66
    /**
67
     * Get the console command options.
68
     *
69
     * @return array
70
     */
71 102
    protected function getOptions()
72
    {
73
        return [
74 102
            ['model', null, InputOption::VALUE_OPTIONAL, 'The Model name for the factory.', null],
75
        ];
76
    }
77
}
78