@@ 7-55 (lines=49) @@ | ||
4 | ||
5 | namespace FondBot\Templates\Keyboard; |
|
6 | ||
7 | class PayloadButton extends Button |
|
8 | { |
|
9 | private $payload; |
|
10 | ||
11 | public function __construct(string $label, $payload, array $parameters = []) |
|
12 | { |
|
13 | parent::__construct($label, $parameters); |
|
14 | ||
15 | $this->payload = $payload; |
|
16 | } |
|
17 | ||
18 | /** |
|
19 | * Make a new payload button instance. |
|
20 | * |
|
21 | * @param string $label |
|
22 | * @param mixed $payload |
|
23 | * @param array $parameters |
|
24 | * |
|
25 | * @return static |
|
26 | */ |
|
27 | public static function make(string $label, $payload, array $parameters = []) |
|
28 | { |
|
29 | return new static($label, $payload, $parameters); |
|
30 | } |
|
31 | ||
32 | /** |
|
33 | * Get payload. |
|
34 | * |
|
35 | * @return mixed |
|
36 | */ |
|
37 | public function getPayload() |
|
38 | { |
|
39 | return $this->payload; |
|
40 | } |
|
41 | ||
42 | /** |
|
43 | * Set payload. |
|
44 | * |
|
45 | * @param mixed $payload |
|
46 | * |
|
47 | * @return PayloadButton |
|
48 | */ |
|
49 | public function setPayload($payload): PayloadButton |
|
50 | { |
|
51 | $this->payload = $payload; |
|
52 | ||
53 | return $this; |
|
54 | } |
|
55 | } |
|
56 |
@@ 7-46 (lines=40) @@ | ||
4 | ||
5 | namespace FondBot\Templates\Keyboard; |
|
6 | ||
7 | class UrlButton extends Button |
|
8 | { |
|
9 | private $url; |
|
10 | ||
11 | public function __construct(string $label, string $url, array $parameters = []) |
|
12 | { |
|
13 | parent::__construct($label, $parameters); |
|
14 | ||
15 | $this->url = $url; |
|
16 | } |
|
17 | ||
18 | public static function make(string $label, string $url, array $parameters = []) |
|
19 | { |
|
20 | return new static($label, $url, $parameters); |
|
21 | } |
|
22 | ||
23 | /** |
|
24 | * Get URL. |
|
25 | * |
|
26 | * @return string |
|
27 | */ |
|
28 | public function getUrl(): string |
|
29 | { |
|
30 | return $this->url; |
|
31 | } |
|
32 | ||
33 | /** |
|
34 | * Set URL. |
|
35 | * |
|
36 | * @param mixed $url |
|
37 | * |
|
38 | * @return UrlButton |
|
39 | */ |
|
40 | public function setUrl($url): UrlButton |
|
41 | { |
|
42 | $this->url = $url; |
|
43 | ||
44 | return $this; |
|
45 | } |
|
46 | } |
|
47 |