SeedGenerator   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 26
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getPath() 0 3 1
A getClassName() 0 3 1
A __construct() 0 4 1
A populateStub() 0 8 1
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