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

SeederMakeCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 74
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getDefaultNamespace() 0 4 1
A getStub() 0 4 1
A generateFile() 0 9 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