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