1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Zored\Telegram\Madeline\Config; |
4
|
|
|
|
5
|
|
|
use JMS\Serializer\Annotation as Serializer; |
6
|
|
|
use Zored\Telegram\Madeline\Config\Auth\AuthConfigInterface; |
7
|
|
|
|
8
|
|
|
final class Config implements ConfigInterface |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* @Serializer\Type("integer") |
12
|
|
|
* |
13
|
|
|
* @var int |
14
|
|
|
*/ |
15
|
|
|
private $id; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @Serializer\Type("string") |
19
|
|
|
* |
20
|
|
|
* @var string |
21
|
|
|
*/ |
22
|
|
|
private $hash; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @Serializer\Type("integer") |
26
|
|
|
* |
27
|
|
|
* @var int |
28
|
|
|
*/ |
29
|
|
|
private $logLevel = LogLevel::NONE; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @Serializer\Type("integer") |
33
|
|
|
* Default: one day. |
34
|
|
|
* |
35
|
|
|
* @var int |
36
|
|
|
*/ |
37
|
|
|
private $authExpiresInSeconds = 86400; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @Serializer\Type("string") |
41
|
|
|
* |
42
|
|
|
* @var string |
43
|
|
|
*/ |
44
|
|
|
private $sessionPath; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var AuthConfigInterface |
48
|
|
|
*/ |
49
|
|
|
private $auth; |
50
|
|
|
|
51
|
|
|
public function __construct( |
52
|
|
|
int $id, |
53
|
|
|
string $hash, |
54
|
|
|
AuthConfigInterface $auth, |
55
|
|
|
string $sessionPath |
56
|
|
|
) { |
57
|
|
|
$this->id = $id; |
58
|
|
|
$this->hash = $hash; |
59
|
|
|
$this->sessionPath = $sessionPath; |
60
|
|
|
$this->auth = $auth; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function setLogLevel(int $logLevel): ConfigInterface |
64
|
|
|
{ |
65
|
|
|
$this->logLevel = $logLevel; |
66
|
|
|
|
67
|
|
|
return $this; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function setAuthExpiresInSeconds(int $authExpiresInSeconds): ConfigInterface |
71
|
|
|
{ |
72
|
|
|
$this->authExpiresInSeconds = $authExpiresInSeconds; |
73
|
|
|
|
74
|
|
|
return $this; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function getId(): int |
78
|
|
|
{ |
79
|
|
|
return $this->id; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function getHash(): string |
83
|
|
|
{ |
84
|
|
|
return $this->hash; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
public function getLogLevel(): int |
88
|
|
|
{ |
89
|
|
|
return $this->logLevel; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
public function getAuthExpiresInSeconds(): int |
93
|
|
|
{ |
94
|
|
|
return $this->authExpiresInSeconds; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
public function getSessionPath(): string |
98
|
|
|
{ |
99
|
|
|
return $this->sessionPath; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
public function setSessionPath(string $sessionPath): ConfigInterface |
103
|
|
|
{ |
104
|
|
|
$this->sessionPath = $sessionPath; |
105
|
|
|
|
106
|
|
|
return $this; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
public function getAuth(): AuthConfigInterface |
110
|
|
|
{ |
111
|
|
|
return $this->auth; |
112
|
|
|
} |
113
|
|
|
} |
114
|
|
|
|