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

Keyboard   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 83.33%

Importance

Changes 0
Metric Value
dl 0
loc 57
ccs 10
cts 12
cp 0.8333
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A create() 0 4 1
A getName() 0 4 1
A getButtons() 0 4 1
A addButton() 0 6 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