| Total Complexity | 2 |
| Total Lines | 29 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 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) |
|
| 31 | } |
||
| 32 | |||
| 33 | abstract public function subType(): string; |
||
| 34 | } |
||
| 35 |