Button   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Test Coverage

Coverage 62.5%

Importance

Changes 0
Metric Value
wmc 6
eloc 12
dl 0
loc 67
c 0
b 0
f 0
ccs 10
cts 16
cp 0.625
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 3 1
A __construct() 0 4 1
A setParameters() 0 5 1
A setLabel() 0 5 1
A getParameters() 0 3 1
A getLabel() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FondBot\Templates\Keyboard;
6
7
use FondBot\Contracts\Template;
8
use Illuminate\Support\Collection;
9
10
abstract class Button implements Template
11
{
12
    protected $label;
13
    protected $parameters;
14
15 3
    public function __construct(string $label, array $parameters = [])
16
    {
17 3
        $this->label = $label;
18 3
        $this->parameters = collect($parameters);
19 3
    }
20
21
    /**
22
     * Get name.
23
     *
24
     * @return string
25
     */
26 3
    public function getName(): string
27
    {
28 3
        return class_basename($this);
29
    }
30
31
    /**
32
     * Get label.
33
     *
34
     * @return string
35
     */
36 3
    public function getLabel(): ?string
37
    {
38 3
        return $this->label;
39
    }
40
41
    /**
42
     * Set label.
43
     *
44
     * @param string $label
45
     *
46
     * @return static
47
     */
48
    public function setLabel(string $label): Button
49
    {
50
        $this->label = $label;
51
52
        return $this;
53
    }
54
55
    /**
56
     * Get button parameters.
57
     *
58
     * @return Collection
59
     */
60 1
    public function getParameters(): Collection
61
    {
62 1
        return $this->parameters;
63
    }
64
65
    /**
66
     * Set parameters.
67
     *
68
     * @param array $parameters
69
     *
70
     * @return static
71
     */
72
    public function setParameters(array $parameters): Button
73
    {
74
        $this->parameters = collect($parameters);
75
76
        return $this;
77
    }
78
}
79