Button   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 29
ccs 9
cts 9
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setIndex() 0 3 1
A toArray() 0 7 1
1
<?php
2
3
namespace NotificationChannels\WhatsApp\Component;
4
5
abstract class Button extends Component
6
{
7
    protected int $index = 0;
8
    protected array $parameters = [];
9
10 4
    public function toArray(): array
11
    {
12 4
        return [
13 4
            'type' => 'button',
14 4
            'sub_type' => $this->subType(), // quick_reply|url
15 4
            'index' => $this->index,
16 4
            'parameters' => $this->parameters,
17 4
        ];
18
    }
19
20
    /**
21
     * From the API
22
     * Position index of the button.
23
     * You can have up to 3 buttons using index values of 0 to 2.
24
     *
25
     * We don't do the validation.
26
     * It's up to the user to follow this guideline
27
     */
28 1
    public function setIndex(int $index)
29
    {
30 1
        $this->index = $index;
31
    }
32
33
    abstract public function subType(): string;
34
}
35