Passed
Pull Request — master (#36)
by Cristian
01:57
created

BackpackCrudModelService::getConsoleOutput()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Webfactor\Laravel\Generators\Services;
4
5
use Illuminate\Contracts\Filesystem\FileNotFoundException;
6
use Webfactor\Laravel\Generators\Contracts\ServiceAbstract;
7
use Webfactor\Laravel\Generators\Contracts\ServiceInterface;
8
use Webfactor\Laravel\Generators\Traits\CanGenerateFile;
9
10
class BackpackCrudModelService extends ServiceAbstract implements ServiceInterface
11
{
12
    use CanGenerateFile;
13
14
    protected $key = 'crudModel';
15
16
    public function getConsoleOutput() {
17
        return 'Generated model: '.$this->command->naming[$this->key]->getRelativeFilePath();
18
    }
19
20
    protected function buildFileContent()
21
    {
22
        $this->replaceClassNamespace();
23
        $this->replaceClassName();
24
        $this->replaceTableName();
25
        $this->replaceFillable();
26
    }
27
28
    protected function replaceFillable()
29
    {
30
        $fillables = $this->command->schema->getStructure()
31
            ->map(function ($item) {
32
                return "'" . $item->name . "'";
33
            });
34
35
        $this->fileContent = str_replace('__fillable__', $fillables->implode(', '), $this->fileContent);
36
    }
37
}
38