Passed
Pull Request — main (#9)
by
unknown
08:34
created

Button::setIndex()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

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