SeedGenerator::getClassName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace PrismX\Generators\Generators;
4
5
use Illuminate\Support\Facades\File;
6
use PrismX\Generators\Support\Model;
7
use PrismX\Generators\Support\AbstractGenerator;
8
9
class SeedGenerator extends AbstractGenerator
10
{
11
    public function __construct(Model $model)
12
    {
13
        parent::__construct($model);
14
        $this->stub = File::get(STUBS_PATH.'/seed.stub');
15
    }
16
17
    protected function getPath(): string
18
    {
19
        return 'database/seeds/'.$this->model->pluralName().'TableSeeder.php';
20
    }
21
22
    public function populateStub(): string
23
    {
24
        $stub = $this->stub;
25
        $stub = str_replace('{{Namespace}}', config('generators.model_namespace'), $stub);
26
        $stub = str_replace('{{ClassName}}', $this->getClassName(), $stub);
27
        $stub = str_replace('{{factoryClass}}', config('generators.model_namespace')."\\{$this->model->name()}", $stub);
28
29
        return $stub;
30
    }
31
32
    protected function getClassName()
33
    {
34
        return $this->model->pluralName().'TableSeeder';
35
    }
36
}
37