Passed
Push — master ( 742978...c607b6 )
by Bruno
05:32
created

CommandValidator   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 54
rs 10
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 19 4
A __construct() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace Formularium\Laravel\Console\Commands;
4
5
use Formularium\Validator;
6
use Formularium\Exception\Exception;
7
use Illuminate\Console\Command;
0 ignored issues
show
Bug introduced by
The type Illuminate\Console\Command 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...
8
9
class CommandValidator extends Command
10
{
11
    /**
12
     * The name and signature of the console command.
13
     *
14
     * @var string
15
     */
16
    protected $signature = 'formularium:validator
17
        {name : The validator name}
18
        {--namespace= : the class namespace. Defaults to "\\App\\Validators"}
19
        {--path= : path to save the file. Defaults to "basepath("app\\Validators") }
20
    ';
21
22
    /**
23
     * The console command description.
24
     *
25
     * @var string
26
     */
27
    protected $description = 'Creates scaffolding using Modelarium';
28
29
    /**
30
     * Create a new command instance.
31
     *
32
     * @return void
33
     */
34
    public function __construct()
35
    {
36
        parent::__construct();
37
    }
38
39
    /**
40
     * Execute the console command.
41
     *
42
     * @return mixed
43
     */
44
    public function handle()
45
    {
46
        $code = Validator::generate(
0 ignored issues
show
Bug introduced by
The method generate() does not exist on Formularium\Validator. ( Ignorable by Annotation )

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

46
        /** @scrutinizer ignore-call */ 
47
        $code = Validator::generate(

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...
47
            $this->option('datatype'),
48
            $this->option('basetype'),
49
            $this->option('namespace') ? $this->option('namespace') : 'App\\Datatypes'
50
        );
51
52
        try {
53
            $retval = Validator::generateFile(
0 ignored issues
show
Bug introduced by
The method generateFile() does not exist on Formularium\Validator. ( Ignorable by Annotation )

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

53
            /** @scrutinizer ignore-call */ 
54
            $retval = Validator::generateFile(

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...
54
                $code,
55
                $this->option('path') ? $this->option('path') : base_path('app/Datatypes')
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

55
                $this->option('path') ? $this->option('path') : /** @scrutinizer ignore-call */ base_path('app/Datatypes')
Loading history...
56
            );
57
58
            $this->line($retval['code']);
59
            $this->line($retval['test']);
60
            $this->info('Finished. You might want to run `composer dump-autoload`');
61
        } catch (Exception $e) {
62
            $this->error($e->getMessage());
63
        }
64
    }
65
}
66