Command::getOptions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 10
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Desemax\ArtisanUI\Http\Resources;
4
5
use Illuminate\Http\Resources\Json\JsonResource;
6
use Symfony\Component\Console\Input\InputArgument;
7
use Symfony\Component\Console\Input\InputOption;
8
9
class Command extends JsonResource
10
{
11
    /**
12
     * Transform the resource into an array.
13
     *
14
     * @param  \Illuminate\Http\Request  $request
15
     * @return array
16
     */
17
    public function toArray($request)
18
    {
19
        return [
20
            'name' => $this->getName(),
0 ignored issues
show
Bug introduced by
The method getName() does not exist on Desemax\ArtisanUI\Http\Resources\Command. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

20
            'name' => $this->/** @scrutinizer ignore-call */ getName(),
Loading history...
21
            'help' => $this->getHelp(),
0 ignored issues
show
Bug introduced by
The method getHelp() does not exist on Desemax\ArtisanUI\Http\Resources\Command. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

21
            'help' => $this->/** @scrutinizer ignore-call */ getHelp(),
Loading history...
22
            'description' => $this->getDescription(),
0 ignored issues
show
Bug introduced by
The method getDescription() does not exist on Desemax\ArtisanUI\Http\Resources\Command. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

22
            'description' => $this->/** @scrutinizer ignore-call */ getDescription(),
Loading history...
23
            'arguments' => $this->getArguments(),
24
            'options' => $this->getOptions(),
25
        ];
26
    }
27
28
    protected function getArguments()
29
    {
30
        return array_map(function (InputArgument $inputArgument) {
31
            return [
32
                'name' => $inputArgument->getName(),
33
                'description' => $inputArgument->getDescription(),
34
                'default' => $inputArgument->getDefault(),
35
                'required' => $inputArgument->isRequired(),
36
            ];
37
        }, $this->getDefinition()->getArguments());
0 ignored issues
show
Bug introduced by
The method getDefinition() does not exist on Desemax\ArtisanUI\Http\Resources\Command. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

37
        }, $this->/** @scrutinizer ignore-call */ getDefinition()->getArguments());
Loading history...
38
    }
39
40
    protected function getOptions()
41
    {
42
        return array_map(function (InputOption $inputOption) {
43
            return [
44
                'name' => $inputOption->getName(),
45
                'description' => $inputOption->getDescription(),
46
                'shortcut' => $inputOption->getShortcut(),
47
                'default' => $inputOption->getDefault(),
48
            ];
49
        }, $this->getDefinition()->getOptions());
50
    }
51
}
52