Button::getLabel()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
c 0
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 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