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.

SignatureParts   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A getSlashCommandName() 0 4 1
A getHandlerName() 0 4 1
A getSignatureWithoutCommandName() 0 4 1
A getArgumentsAndOptions() 0 4 1
1
<?php
2
3
namespace Spatie\SlashCommand\Handlers;
4
5
use Illuminate\Support\Str;
6
use Spatie\SlashCommand\Exceptions\InvalidSignature;
7
8
class SignatureParts
9
{
10
    /** @var string */
11
    protected $signature;
12
13
    public function __construct(string $signature)
14
    {
15
        $this->signature = $signature;
16
17
        if (! Str::contains($this->signature, ' ')) {
18
            throw InvalidSignature::signatureMustContainASpace($this->signature);
19
        }
20
    }
21
22
    public function getSlashCommandName(): string
23
    {
24
        return ltrim(explode(' ', $this->signature)[0], '/');
25
    }
26
27
    public function getHandlerName(): string
28
    {
29
        return explode(' ', $this->signature)[1];
30
    }
31
32
    public function getSignatureWithoutCommandName(): string
33
    {
34
        return explode(' ', $this->signature, 2)[1];
35
    }
36
37
    public function getArgumentsAndOptions(): string
38
    {
39
        return explode(' ', $this->signature, 3)[2];
40
    }
41
}
42