Passed
Pull Request — master (#36)
by Cristian
02:10
created

BackpackCrudRequestService   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 2
cbo 4
dl 0
loc 24
ccs 0
cts 14
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getConsoleOutput() 0 4 1
A buildFileContent() 0 6 1
A replaceValidationRules() 0 4 1
1
<?php
2
3
namespace Webfactor\Laravel\Generators\Services;
4
5
use Webfactor\Laravel\Generators\Contracts\SchemaFieldAbstract;
6
use Webfactor\Laravel\Generators\Contracts\ServiceAbstract;
7
use Webfactor\Laravel\Generators\Contracts\ServiceInterface;
8
use Webfactor\Laravel\Generators\Helper\ShortSyntaxArray;
9
use Webfactor\Laravel\Generators\Traits\CanGenerateFile;
10
11
class BackpackCrudRequestService extends ServiceAbstract implements ServiceInterface
12
{
13
    use CanGenerateFile;
14
15
    protected $key = 'crudRequest';
16
17
    public function getConsoleOutput()
18
    {
19
        return 'Generated request: '.$this->command->naming[$this->key]->getRelativeFilePath();
20
    }
21
22
    protected function buildFileContent()
23
    {
24
        $this->replaceClassNamespace();
25
        $this->replaceClassName();
26
        $this->replaceValidationRules();
27
    }
28
29
    protected function replaceValidationRules()
30
    {
31
        $this->fileContent = str_replace('__rules__', ShortSyntaxArray::parse($this->command->schema->getValidationRules()->toArray()), $this->fileContent);
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 156 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
32
    }
33
34
}
35