Completed
Push — master ( 8de31e...457641 )
by Vladimir
02:57
created

Keyboard::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FondBot\Templates;
6
7
use FondBot\Contracts\Template;
8
use FondBot\Templates\Keyboard\Button;
9
10
class Keyboard implements Template
11
{
12
    /** @var Button[] */
13
    private $buttons;
14
15
    /**
16
     * @param Button[] $buttons
17
     */
18 1
    public function __construct(array $buttons = [])
19
    {
20 1
        $this->buttons = $buttons;
21 1
    }
22
23
    /**
24
     * @param Button[] $buttons
25
     *
26
     * @return static
27
     */
28
    public static function create(array $buttons = [])
29
    {
30
        return new static($buttons);
31
    }
32
33
    /**
34
     * Get name.
35
     *
36
     * @return string
37
     */
38 1
    public function getName(): string
39
    {
40 1
        return 'Keyboard';
41
    }
42
43
    /**
44
     * Get buttons.
45
     *
46
     * @return Button[]
47
     */
48 1
    public function getButtons(): array
49
    {
50 1
        return $this->buttons;
51
    }
52
53
    /**
54
     * Add button.
55
     *
56
     * @param Button $button
57
     *
58
     * @return Keyboard
59
     */
60 1
    public function addButton(Button $button): Keyboard
61
    {
62 1
        $this->buttons[] = $button;
63
64 1
        return $this;
65
    }
66
}
67