GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

ValidatorCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 86
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 86
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
A fire() 0 15 2
A getArguments() 0 11 1
A getOptions() 0 19 1
1
<?php
2
3
namespace Milkmeowo\Framework\Repository\Generators\Commands;
4
5
use Illuminate\Console\Command;
6
use Symfony\Component\Console\Input\InputOption;
7
use Symfony\Component\Console\Input\InputArgument;
8
use Milkmeowo\Framework\Repository\Generators\ValidatorGenerator;
9
use Milkmeowo\Framework\Repository\Generators\Exceptions\FileAlreadyExistsException;
10
11
class ValidatorCommand extends Command
12
{
13
    /**
14
     * The name of command.
15
     *
16
     * @var string
17
     */
18
    protected $name = 'starter:validator';
19
20
    /**
21
     * The description of command.
22
     *
23
     * @var string
24
     */
25
    protected $description = 'Create a new validator.';
26
27
    /**
28
     * The type of class being generated.
29
     *
30
     * @var string
31
     */
32
    protected $type = 'Validator';
33
34
    /**
35
     * Execute the command.
36
     *
37
     * @return void
38
     */
39
    public function fire()
40
    {
41
        try {
42
            (new ValidatorGenerator([
43
                'name' => $this->argument('name'),
44
                'rules' => $this->option('rules'),
45
                'force' => $this->option('force'),
46
            ]))->run();
47
            $this->info('Validator created successfully.');
48
        } catch (FileAlreadyExistsException $e) {
49
            $this->error($this->type.' already exists!');
50
51
            return false;
52
        }
53
    }
54
55
    /**
56
     * The array of command arguments.
57
     *
58
     * @return array
59
     */
60
    public function getArguments()
61
    {
62
        return [
63
            [
64
                'name',
65
                InputArgument::REQUIRED,
66
                'The name of model for which the validator is being generated.',
67
                null,
68
            ],
69
        ];
70
    }
71
72
    /**
73
     * The array of command options.
74
     *
75
     * @return array
76
     */
77
    public function getOptions()
78
    {
79
        return [
80
            [
81
                'rules',
82
                null,
83
                InputOption::VALUE_OPTIONAL,
84
                'The rules of validation attributes.',
85
                null,
86
            ],
87
            [
88
                'force',
89
                'f',
90
                InputOption::VALUE_NONE,
91
                'Force the creation if file already exists.',
92
                null,
93
            ],
94
        ];
95
    }
96
}
97