1 | <?php |
||
5 | class WebUrl extends AbstractButtons |
||
6 | { |
||
7 | |||
8 | const RATIO_TYPE_COMPACT = 'compact'; |
||
9 | const RATIO_TYPE_TALL = 'tall'; |
||
10 | const RATIO_TYPE_FULL = 'full'; |
||
11 | |||
12 | /** |
||
13 | * @var string |
||
14 | */ |
||
15 | protected $title; |
||
16 | |||
17 | /** |
||
18 | * @var string |
||
19 | */ |
||
20 | protected $url; |
||
21 | |||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $webviewHeightRatio; |
||
26 | |||
27 | /** |
||
28 | * @var null|bool |
||
29 | */ |
||
30 | protected $messengerExtension; |
||
31 | |||
32 | /** |
||
33 | * @var null|string |
||
34 | */ |
||
35 | protected $fallbackUrl; |
||
36 | |||
37 | /** |
||
38 | * @var null|string |
||
39 | */ |
||
40 | protected $webviewShareButton; |
||
41 | |||
42 | /** |
||
43 | * WebUrl constructor. |
||
44 | * |
||
45 | * @param string $title |
||
46 | * @param string $url |
||
47 | */ |
||
48 | 9 | public function __construct(string $title, string $url) |
|
58 | |||
59 | /** |
||
60 | * @param string $webviewHeightRatio |
||
61 | * @return WebUrl |
||
62 | */ |
||
63 | 6 | public function setWebviewHeightRatio(string $webviewHeightRatio): WebUrl |
|
64 | { |
||
65 | 6 | $allowedRatioType = $this->getAllowedRatioType(); |
|
66 | 6 | if (!in_array($webviewHeightRatio, $allowedRatioType)) { |
|
67 | throw new \InvalidArgumentException('$webviewHeightRatio must be either ' . implode(',', $allowedRatioType)); |
||
68 | } |
||
69 | 6 | $this->webviewHeightRatio = $webviewHeightRatio; |
|
70 | |||
71 | 6 | return $this; |
|
72 | } |
||
73 | |||
74 | /** |
||
75 | * @param bool $messengerExtension |
||
76 | * @return WebUrl |
||
77 | */ |
||
78 | 4 | public function setMessengerExtension(bool $messengerExtension): WebUrl |
|
84 | |||
85 | /** |
||
86 | * @param string $fallbackUrl |
||
87 | * @return WebUrl |
||
88 | */ |
||
89 | 3 | public function setFallbackUrl(string $fallbackUrl): WebUrl |
|
96 | |||
97 | 1 | public function setWebviewShareButton(bool $webviewShareButton): WebUrl |
|
105 | |||
106 | /** |
||
107 | * @return array |
||
108 | */ |
||
109 | 6 | private function getAllowedRatioType(): array |
|
117 | |||
118 | /** |
||
119 | * @return array |
||
120 | */ |
||
121 | 8 | public function jsonSerialize(): array |
|
135 | } |
||
136 |