SeederMakeCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 30.76%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 74
ccs 4
cts 13
cp 0.3076
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 2
    public function __construct()
37
    {
38 2
        parent::__construct();
39
40 2
        $this->setStubDirectory(__DIR__.'/../../stubs');
41 2
    }
42
43
    /**
44
     * Get the default namespace for the class.
45
     *
46
     * @return string
47
     */
48
    protected function getDefaultNamespace()
49
    {
50
        return $this->getRootNamespace().'\\Database\\Seeds';
51
    }
52
53
    /**
54
     * Get the stub file for the generator.
55
     *
56
     * @return string
57
     */
58
    protected function getStub()
59
    {
60
        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
    protected function generateFile(FileGenerator $generator, $path, $fqcn)
73
    {
74
        list($namespace, $class) = $this->splitFullQualifyClassName($fqcn);
75
76
        return $generator->file($path)->template($this->getStub(), [
77
            'namespace' => $namespace,
78
            'class' => $class,
79
        ]);
80
    }
81
}
82