Passed
Push — master ( 719292...2fce0a )
by Sebastien
05:40
created

Routes   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 27
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 22 2
1
<?php
2
3
namespace Sebastienheyd\BoilerplatePackager\Commands\Crud;
4
5
class Routes extends Command
6
{
7
    protected $signature = 'boilerplate:packager:crud:routes {package} {tables}';
8
    protected $description = '';
9
10
    public function handle()
11
    {
12
        $package = $this->argument('package');
13
        [$vendor, $packageName] = explode('/', $package);
0 ignored issues
show
Bug introduced by
It seems like $package can also be of type null and string[]; however, parameter $string of explode() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

13
        [$vendor, $packageName] = explode('/', /** @scrutinizer ignore-type */ $package);
Loading history...
14
15
        $relations = [];
16
        foreach ($this->argument('tables') as $table) {
17
            $relations[$table] = $this->getTableRelations($table);
18
        }
19
20
//        dd($relations);
21
22
        $routes = (string) view('packager::routes', [
23
            'models' => $this->argument('tables'),
24
            'namespace' => $this->getNamespace($this->argument('package')),
25
            'vendor' => $vendor,
26
            'package' => $packageName,
27
            'relations' => $relations,
28
        ]);
29
30
        $this->info('Writing routes');
31
        $this->storage->put($package.'/src/routes/'.$packageName.'.php', $routes);
0 ignored issues
show
Bug introduced by
Are you sure $package of type null|string|string[] can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

31
        $this->storage->put(/** @scrutinizer ignore-type */ $package.'/src/routes/'.$packageName.'.php', $routes);
Loading history...
32
    }
33
}
34