|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Kerox\Messenger\Model\ProfileSettings; |
|
6
|
|
|
|
|
7
|
|
|
use Kerox\Messenger\Helper\ValidatorTrait; |
|
8
|
|
|
use Kerox\Messenger\Model\Common\Button\WebUrl; |
|
9
|
|
|
|
|
10
|
|
|
class HomeUrl implements \JsonSerializable |
|
11
|
|
|
{ |
|
12
|
|
|
use ValidatorTrait; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* @var string |
|
16
|
|
|
*/ |
|
17
|
|
|
protected $url; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @var string |
|
21
|
|
|
*/ |
|
22
|
|
|
protected $webviewHeightRation; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var string |
|
26
|
|
|
*/ |
|
27
|
|
|
protected $webviewShareButton; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var bool |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $inTest; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* HomeUrl constructor. |
|
36
|
|
|
* |
|
37
|
|
|
* @throws \Kerox\Messenger\Exception\InvalidUrlException |
|
38
|
|
|
*/ |
|
39
|
1 |
|
public function __construct( |
|
40
|
|
|
string $url, |
|
41
|
|
|
string $webviewHeightRation = WebUrl::RATIO_TYPE_TALL, |
|
42
|
|
|
string $webviewShareButton = 'hide', |
|
43
|
|
|
bool $inTest = true |
|
44
|
|
|
) { |
|
45
|
1 |
|
$this->isValidUrl($url); |
|
46
|
|
|
|
|
47
|
1 |
|
$this->url = $url; |
|
48
|
1 |
|
$this->webviewHeightRation = $webviewHeightRation; |
|
49
|
1 |
|
$this->webviewShareButton = $webviewShareButton; |
|
50
|
1 |
|
$this->inTest = $inTest; |
|
51
|
1 |
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @throws \Kerox\Messenger\Exception\InvalidUrlException |
|
55
|
|
|
* |
|
56
|
|
|
* @return \Kerox\Messenger\Model\ProfileSettings\HomeUrl |
|
57
|
|
|
*/ |
|
58
|
1 |
|
public static function create( |
|
59
|
|
|
string $url, |
|
60
|
|
|
string $webviewHeightRation = WebUrl::RATIO_TYPE_TALL, |
|
61
|
|
|
string $webviewShareButton = 'hide', |
|
62
|
|
|
bool $inTest = true |
|
63
|
|
|
): self { |
|
64
|
1 |
|
return new self($url, $webviewHeightRation, $webviewShareButton, $inTest); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
1 |
|
public function toArray(): array |
|
68
|
|
|
{ |
|
69
|
|
|
return [ |
|
70
|
1 |
|
'url' => $this->url, |
|
71
|
1 |
|
'webview_height_ration' => $this->webviewHeightRation, |
|
72
|
1 |
|
'webview_share_button' => $this->webviewShareButton, |
|
73
|
1 |
|
'in_test' => $this->inTest, |
|
74
|
|
|
]; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
1 |
|
public function jsonSerialize(): array |
|
78
|
|
|
{ |
|
79
|
1 |
|
return $this->toArray(); |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|