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.

MakeEnum::getStub()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 1
c 1
b 0
f 1
dl 0
loc 3
rs 10
ccs 1
cts 1
cp 1
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Spatie\Enum\Laravel\Commands;
4
5
use Illuminate\Console\GeneratorCommand;
6
use Symfony\Component\Console\Input\InputArgument;
7
use Symfony\Component\Console\Input\InputOption;
8
9
class MakeEnum extends GeneratorCommand
10
{
11
    protected $name = 'make:enum';
12
13
    protected $description = 'Create a new enum';
14
15 36
    public function handle()
16
    {
17 36
        $this->type = $this->getNameInput();
18
19
        return parent::handle();
20 36
    }
21
22 36
    protected function getStub()
23
    {
24
        return __DIR__.'/../../stubs/enum.php.stub';
25 36
    }
26
27 36
    protected function getDefaultNamespace($rootNamespace)
28
    {
29 36
        return $rootNamespace.'\Enums';
30 36
    }
31
32 36
    protected function replaceClass($stub, $name)
33
    {
34
        $stub = parent::replaceClass($stub, $name);
35 36
36
        $stub = str_replace('/** DummyDocBlock */', $this->getDocBlock(), $stub);
37 36
38
        return $stub;
39 36
    }
40 32
41
    protected function getDocBlock(): string
42 32
    {
43 32
        $methods = $this->option('method');
44 32
45
        if (! empty($methods)) {
46
            $docBlock = PHP_EOL.'/**';
47 36
            $docBlock .= implode('', array_map(function ($method) {
48
                return PHP_EOL.' * @method static self '.$method.'()';
49
            }, $methods));
0 ignored issues
show
Bug introduced by
It seems like $methods can also be of type boolean and string; however, parameter $arr1 of array_map() does only seem to accept array, 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

49
            }, /** @scrutinizer ignore-type */ $methods));
Loading history...
50 36
            $docBlock .= PHP_EOL.' */';
51
        }
52 36
53
        return $docBlock ?? '';
54 36
    }
55 16
56 16
    protected function getArguments()
57
    {
58 16
        return [
59 16
            ['name', InputArgument::REQUIRED, 'The name of the enum'],
60
        ];
61
    }
62 16
63
    protected function getOptions()
64
    {
65 36
        return [
66
            ['method', 'm', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'The method name that should be added to the enum'],
67
        ];
68 32
    }
69
}
70