Passed
Push — master ( cd2210...3cb518 )
by Thomas
39s
created

MakeMigrationService   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 21
ccs 0
cts 16
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A make() 0 8 1
A getName() 0 4 1
A getSchema() 0 4 1
1
<?php
2
3
namespace Webfactor\Laravel\Generators\Services;
4
5
use Webfactor\Laravel\Generators\Contracts\MakeServiceAbstract;
6
use Webfactor\Laravel\Generators\Contracts\MakeServiceInterface;
7
8
class MakeMigrationService extends MakeServiceAbstract implements MakeServiceInterface
9
{
10
    public function make()
11
    {
12
        $this->command->call('make:migration:schema', [
13
            'name' => $this->getName($this->entity),
14
            '--model' => 0,
15
            '--schema' => $this->getSchema(),
16
        ]);
17
    }
18
19
    public function getName(string $entity): string
20
    {
21
        return 'create_' . snake_case(str_plural($entity)) . '_table';
22
    }
23
24
    private function getSchema()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
25
    {
26
        return $this->command->option('schema') ?? 'name:string';
27
    }
28
}
29