Passed
Push — master ( 23ad8b...41e1cb )
by Bruno
05:36
created

ModelariumFrontendCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 0
1
<?php declare(strict_types=1);
2
3
namespace Modelarium\Laravel\Console\Commands;
4
5
use Formularium\FrameworkComposer;
6
use Formularium\Model;
7
use Illuminate\Console\Command;
8
use Modelarium\Frontend\FrontendGenerator;
0 ignored issues
show
Bug introduced by
The type Modelarium\Frontend\FrontendGenerator was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
10
class ModelariumFrontendCommand extends Command
11
{
12
    use WriterTrait;
0 ignored issues
show
introduced by
The trait Modelarium\Laravel\Console\Commands\WriterTrait requires some properties which are not provided by Modelarium\Laravel\Conso...delariumFrontendCommand: $filename, $onlyIfNewFile, $contents
Loading history...
13
14
    /**
15
     * The name and signature of the console command.
16
     *
17
     * @var string
18
     */
19
    protected $signature = 'modelarium:frontend
20
        {name : The model name. Use "*" or "all" for all models}
21
        {--framework=* : The frameworks to use}
22
    ';
23
24
    /**
25
     * The console command description.
26
     *
27
     * @var string
28
     */
29
    protected $description = 'Creates frontend using Modelarium';
30
31
    /**
32
     * Create a new command instance.
33
     *
34
     * @return void
35
     */
36
    public function __construct()
37
    {
38
        parent::__construct();
39
    }
40
41
    /**
42
     * Execute the console command.
43
     *
44
     * @return mixed
45
     */
46
    public function handle()
47
    {
48
        $name = $this->argument('name');
49
50
        // setup stuff
51
        $frameworks = $this->option('framework');
52
        if (empty($frameworks)) {
53
            $this->error('If you are generating frontend you need to specify frameworks. Example: `--framework=HTML --framework=Bootstrap --framework=Vue`');
54
            return;
55
        }
56
57
        $this->info('Generating Frontend.');
58
      
59
        $composer = FrameworkComposer::create($frameworks);
0 ignored issues
show
Bug introduced by
The method create() does not exist on Formularium\FrameworkComposer. ( Ignorable by Annotation )

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

59
        /** @scrutinizer ignore-call */ 
60
        $composer = FrameworkComposer::create($frameworks);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
60
61
        if ($name === '*' || $name === 'all') {
62
            // TODO: all classes
63
        } else {
64
            $model = $name::getFormularium();
65
            $generator = new FrontendGenerator($composer, $model);
66
            $collection = $generator->generate();
67
        }
68
69
        $this->writeFiles(
70
            $collection,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $collection does not seem to be defined for all execution paths leading up to this point.
Loading history...
71
            base_path(),
0 ignored issues
show
Bug introduced by
The function base_path was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

71
            /** @scrutinizer ignore-call */ 
72
            base_path(),
Loading history...
72
            (bool)$this->option('overwrite')
73
        );
74
        $this->info('Finished frontend.');
75
    }
76
}
77