Button::setIndex()   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 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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