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.
Completed
Push — master ( 0e5848...31dbe9 )
by Freek
02:04
created

SignatureHandler::parseInput()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 20
Code Lines 10

Duplication

Lines 20
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 20
loc 20
rs 9.4285
cc 3
eloc 10
nc 4
nop 0
1
<?php
2
3
namespace Spatie\SlashCommand\Handlers;
4
5
use Illuminate\Console\Parser;
6
use Spatie\SlashCommand\Exceptions\InvalidHandler;
7
use Spatie\SlashCommand\Request;
8
use Symfony\Component\Console\Input\InputDefinition;
9
use Symfony\Component\Console\Input\StringInput;
10
11
abstract class SignatureHandler extends BaseHandler
12
{
13
    /** @var string */
14
    protected $name;
15
16
    /** @var \Symfony\Component\Console\Input\StringInput */
17
    protected $input;
18
19
    public function __construct(Request $request)
20
    {
21
        parent::__construct($request);
22
23
        if (empty($this->signature)) {
0 ignored issues
show
Bug introduced by
The property signature does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
24
            throw InvalidHandler::noSignatureSet(static::class);
25
        }
26
27
        $this->parseSignature();
0 ignored issues
show
Bug introduced by
The method parseSignature() does not seem to exist on object<Spatie\SlashComma...dlers\SignatureHandler>.

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...
28
    }
29
30 View Code Duplication
    protected function parseInput()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
31
    {
32
        list($name, $arguments, $options) = Parser::parse($this->signature);
33
34
        $this->name = $name;
35
36
        $inputDefinition = new InputDefinition();
37
38
        foreach ($arguments as $argument) {
39
            $inputDefinition->addArgument($argument);
40
        }
41
42
        foreach($options as $option) {
43
            $inputDefinition->addOption($option);
44
        }
45
46
        $this->input = new StringInput($this->request->text);
47
48
        $this->input->bind($inputDefinition);
49
    }
50
51
52
    protected function getArgument($foo)
53
    {
54
        return $this->input->getArgument($foo);
55
    }
56
57
    protected function getOption($foo)
58
    {
59
        return $this->input->getOption($foo);
60
    }
61
}
62