1 | <?php |
||
20 | final class ClientFactory |
||
21 | { |
||
22 | /** |
||
23 | * |
||
24 | */ |
||
25 | private CONST AUTH_ENUM = [Client::AUTH_NONE, Client::AUTH_PLAIN, Client::AUTH_LOGIN, Client::AUTH_AUTO]; |
||
26 | /** |
||
27 | * @var ConnectionInterface |
||
28 | */ |
||
29 | private $connection; |
||
30 | /** |
||
31 | * @var string |
||
32 | */ |
||
33 | private $password = ''; |
||
34 | /** |
||
35 | * @var float |
||
36 | */ |
||
37 | private $timeout = 1; |
||
38 | /** |
||
39 | * @var string |
||
40 | */ |
||
41 | private $username = ''; |
||
42 | /** |
||
43 | * @var string |
||
44 | */ |
||
45 | private $ehlo = '127.0.0.1'; |
||
46 | /** |
||
47 | * @var int |
||
48 | */ |
||
49 | private $authMethod = Client::AUTH_NONE; |
||
50 | /** |
||
51 | * @var bool |
||
52 | */ |
||
53 | private $insecureConnectionAllowed = false; |
||
54 | /** |
||
55 | * @var string |
||
56 | */ |
||
57 | private $reconnectAfter = 'PT300S'; |
||
58 | /** |
||
59 | * @var int |
||
60 | */ |
||
61 | private $startTls; |
||
62 | |||
63 | /** |
||
64 | * ClientFactory constructor. |
||
65 | * @param ConnectionInterface $connection |
||
66 | */ |
||
67 | 10 | public function __construct(ConnectionInterface $connection) |
|
68 | { |
||
69 | 10 | $this->connection = $connection; |
|
70 | 10 | $this->startTls = CryptoConstant::getDefaultMethod(PHP_VERSION); |
|
71 | 10 | } |
|
72 | |||
73 | /** |
||
74 | * @param float $connectionTimeout |
||
75 | * @return ClientFactory |
||
76 | */ |
||
77 | 1 | public function withTimeout(float $connectionTimeout): ClientFactory |
|
83 | |||
84 | /** |
||
85 | * @param int $method |
||
86 | * @param string $password |
||
87 | * @param string $username |
||
88 | * @return ClientFactory |
||
89 | */ |
||
90 | 3 | public function withAuthentication(int $method, string $username, string $password): ClientFactory |
|
102 | |||
103 | /** |
||
104 | * @param string $ehlo |
||
105 | * @return ClientFactory |
||
106 | */ |
||
107 | 4 | public function withEhlo(string $ehlo): ClientFactory |
|
113 | |||
114 | /** |
||
115 | * @return ClientFactory |
||
116 | */ |
||
117 | 2 | public function withInsecureConnectionAllowed(): ClientFactory |
|
123 | |||
124 | /** |
||
125 | * @param int $crypto |
||
126 | * @return ClientFactory |
||
127 | */ |
||
128 | public function withStartTls(int $crypto): ClientFactory |
||
134 | |||
135 | /** |
||
136 | * @return ClientFactory |
||
137 | */ |
||
138 | 1 | public function withoutStartTls(): ClientFactory |
|
144 | |||
145 | /** |
||
146 | * @return Client |
||
147 | */ |
||
148 | 8 | public function newClient(): Client |
|
185 | |||
186 | /** |
||
187 | * @param string $dataSourceName |
||
188 | * @return ClientFactory |
||
189 | */ |
||
190 | 7 | public static function fromString(string $dataSourceName):ClientFactory |
|
264 | } |
||
265 |