Completed
Push — master ( aed5e6...e7b04e )
by Fumio
01:47
created

SeederMakeCommand::getDefaultNamespace()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Jumilla\Versionia\Laravel\Commands;
4
5
use Jumilla\Generators\Laravel\OneFileGeneratorCommand as BaseCommand;
6
use Jumilla\Generators\FileGenerator;
7
8
class SeederMakeCommand extends BaseCommand
9
{
10
    /**
11
     * The console command singature.
12
     *
13
     * @var stringphp
14
     */
15
    protected $signature = 'make:seeder
16
        {name : The name of the class}
17
    ';
18
19
    /**
20
     * The console command description.
21
     *
22
     * @var string
23
     */
24
    protected $description = 'Create a new seeder class';
25
26
    /**
27
     * The type of class being generated.
28
     *
29
     * @var string
30
     */
31
    protected $type = 'Seeder';
32
33
    /**
34
     * The constructor.
35
     */
36 3
    public function __construct()
37
    {
38 3
        parent::__construct();
39
40 3
        $this->setStubDirectory(__DIR__.'/../../stubs');
41 3
    }
42
43
    /**
44
     * Get the default namespace for the class.
45
     *
46
     * @return string
47
     */
48 1
    protected function getDefaultNamespace()
49
    {
50 1
        return $this->getRootNamespace().'\\Database\\Seeds';
51
    }
52
53
    /**
54
     * Get the stub file for the generator.
55
     *
56
     * @return string
57
     */
58 1
    protected function getStub()
59
    {
60 1
        return 'seeder.stub';
61
    }
62
63
    /**
64
     * Generate file.
65
     *
66
     * @param FileGenerator $generator
67
     * @param string        $path
68
     * @param string        $fqcn
69
     *
70
     * @return bool
71
     */
72 1
    protected function generateFile(FileGenerator $generator, $path, $fqcn)
73
    {
74 1
        list($namespace, $class) = $this->splitFullQualifyClassName($fqcn);
75
76 1
        return $generator->file($path)->template($this->getStub(), [
77 1
            'namespace' => $namespace,
78 1
            'class' => $class,
79
        ]);
80
    }
81
}
82