Completed
Push — main ( 81f3f2...e66a81 )
by Alejandro
15s queued 13s
created

Button   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 28
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setIndex() 0 2 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
    public function toArray(): array
11
    {
12
        return [
13
            'type' => 'button',
14
            'sub_type' => $this->subType(), // quick_reply|url
15
            'index' => $this->index,
16
            'parameters' => $this->parameters
17
        ];
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
    public function setIndex(int $index){
29
        $this->index = $index;
30
    }
31
32
    public abstract function subType(): string;
33
}
34